[systemd-commits] src/log.c src/log.h

Lennart Poettering lennart at kemper.freedesktop.org
Wed Mar 14 06:54:48 PDT 2012


 src/log.c |   27 ++++++++++++++++++++-------
 src/log.h |    9 +++++++++
 2 files changed, 29 insertions(+), 7 deletions(-)

New commits:
commit 17a949114db25546973989bbdcc0c71f0a5e3503
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Mar 14 14:54:41 2012 +0100

    log: introduce log_metav

diff --git a/src/log.c b/src/log.c
index e1f511c..9499367 100644
--- a/src/log.c
+++ b/src/log.c
@@ -582,26 +582,22 @@ int log_dump_internal(
         return r;
 }
 
-int log_meta(
+int log_metav(
         int level,
         const char*file,
         int line,
         const char *func,
-        const char *format, ...) {
+        const char *format,
+        va_list ap) {
 
         char buffer[LINE_MAX];
         int saved_errno, r;
-        va_list ap;
 
         if (_likely_(LOG_PRI(level) > log_max_level))
                 return 0;
 
         saved_errno = errno;
-
-        va_start(ap, format);
         vsnprintf(buffer, sizeof(buffer), format, ap);
-        va_end(ap);
-
         char_array_0(buffer);
 
         r = log_dispatch(level, file, line, func, buffer);
@@ -610,6 +606,23 @@ int log_meta(
         return r;
 }
 
+int log_meta(
+        int level,
+        const char*file,
+        int line,
+        const char *func,
+        const char *format, ...) {
+
+        int r;
+        va_list ap;
+
+        va_start(ap, format);
+        r = log_metav(level, file, line, func, format, ap);
+        va_end(ap);
+
+        return r;
+}
+
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
 _noreturn_ static void log_assert(const char *text, const char *file, int line, const char *func, const char *format) {
diff --git a/src/log.h b/src/log.h
index 7028a13..cf9f7fa 100644
--- a/src/log.h
+++ b/src/log.h
@@ -24,6 +24,7 @@
 
 #include <syslog.h>
 #include <stdbool.h>
+#include <stdarg.h>
 
 #include "macro.h"
 
@@ -73,6 +74,14 @@ int log_meta(
         const char *func,
         const char *format, ...) _printf_attr_(5,6);
 
+int log_metav(
+        int level,
+        const char*file,
+        int line,
+        const char *func,
+        const char *format,
+        va_list ap);
+
 _noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func);
 _noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func);
 



More information about the systemd-commits mailing list