(no commit message)
[strongswan.git] / src / libstrongswan / utils / logger.c
index de323bb..26f4253 100644 (file)
@@ -22,7 +22,6 @@
  */
 
 #include <syslog.h>
  */
 
 #include <syslog.h>
-#include <stdarg.h>
 #include <string.h>
 #include <stdio.h>
 #include <time.h>
 #include <string.h>
 #include <stdio.h>
 #include <time.h>
@@ -30,7 +29,6 @@
 
 #include "logger.h"
 
 
 #include "logger.h"
 
-
 /**
  * Maximum length of a log entry (only used for logger_s.log).
  */
 /**
  * Maximum length of a log entry (only used for logger_s.log).
  */
@@ -180,40 +178,43 @@ static int get_priority(log_level_t loglevel)
 }
 
 /**
 }
 
 /**
- * Implementation of logger_t.log.
- *
- * Yes, logg is written wrong :-).
+ * Implementation of logger_t.logv.
  */
  */
-static void logg(private_logger_t *this, log_level_t loglevel, const char *format, ...)
+static void logv(private_logger_t *this, log_level_t loglevel, const char *format, va_list args)
 {
        if ((this->level & loglevel) == loglevel)
        {
                char buffer[MAX_LOG];
 {
        if ((this->level & loglevel) == loglevel)
        {
                char buffer[MAX_LOG];
-               va_list args;
                
                
-
                if (this->output == NULL)
                {
                        /* syslog */
                        prepend_prefix(this, loglevel, format, buffer);
                if (this->output == NULL)
                {
                        /* syslog */
                        prepend_prefix(this, loglevel, format, buffer);
-                       va_start(args, format);
                        vsyslog(get_priority(loglevel), buffer, args);
                        vsyslog(get_priority(loglevel), buffer, args);
-                       va_end(args);
                }
                else
                {
                        /* File output */
                        prepend_prefix(this, loglevel, format, buffer);
                }
                else
                {
                        /* File output */
                        prepend_prefix(this, loglevel, format, buffer);
-                       va_start(args, format);
                        vfprintf(this->output, buffer, args);
                        vfprintf(this->output, buffer, args);
-                       va_end(args);
                        fprintf(this->output, "\n");
                }
                        fprintf(this->output, "\n");
                }
-
        }
 }
 
 /**
        }
 }
 
 /**
+ * Implementation of logger_t.log.
+ */
+static void logg(private_logger_t *this, log_level_t loglevel, const char *format, ...)
+{
+       va_list args;
+       
+       va_start(args, format);
+       logv(this, loglevel, format, args);
+       va_end(args);
+}
+
+/**
  * Implementation of logger_t.log_bytes.
  */
 static void log_bytes(private_logger_t *this, log_level_t loglevel, const char *label, const char *bytes, size_t len)
  * Implementation of logger_t.log_bytes.
  */
 static void log_bytes(private_logger_t *this, log_level_t loglevel, const char *label, const char *bytes, size_t len)
@@ -357,6 +358,7 @@ logger_t *logger_create(char *logger_name, log_level_t log_level, bool log_threa
        
        /* public functions */
        this->public.log = (void(*)(logger_t*,log_level_t,const char*,...))logg;
        
        /* public functions */
        this->public.log = (void(*)(logger_t*,log_level_t,const char*,...))logg;
+       this->public.logv = (void(*)(logger_t*,log_level_t,const char*,va_list))logv;
        this->public.log_bytes = (void(*)(logger_t*, log_level_t, const char*, const char*,size_t))log_bytes;
        this->public.log_chunk = log_chunk;
        this->public.enable_level = (void(*)(logger_t*,log_level_t))enable_level;
        this->public.log_bytes = (void(*)(logger_t*, log_level_t, const char*, const char*,size_t))log_bytes;
        this->public.log_chunk = log_chunk;
        this->public.enable_level = (void(*)(logger_t*,log_level_t))enable_level;