---
 include/proto/log.h |   12 ++++++++++++
 src/log.c           |   35 ++++++++++++++++++++++++++++-------
 2 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/include/proto/log.h b/include/proto/log.h
index f2ecf0b..45bec88 100644
--- a/include/proto/log.h
+++ b/include/proto/log.h
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include <syslog.h>
+#include <stdarg.h>
 
 #include <common/config.h>
 #include <common/memory.h>
@@ -38,12 +39,23 @@ extern struct pool_head *pool2_requri;
  * Displays the message on stderr with the date and pid. Overrides the quiet
  * mode during startup.
  */
+void vAlert(const char *fmt, va_list argp);
+
+/*
+ * Displays the message on stderr with the date and pid. Overrides the quiet
+ * mode during startup.
+ */
 void Alert(const char *fmt, ...)
        __attribute__ ((format(printf, 1, 2)));
 
 /*
  * Displays the message on stderr with the date and pid.
  */
+void vWarning(const char *fmt, va_list argp);
+
+/*
+ * Displays the message on stderr with the date and pid.
+ */
 void Warning(const char *fmt, ...)
        __attribute__ ((format(printf, 1, 2)));
 
diff --git a/src/log.c b/src/log.c
index 119536c..4cd3b55 100644
--- a/src/log.c
+++ b/src/log.c
@@ -91,6 +91,17 @@ static void __Alert(int send_log, const char *fmt, va_list 
argp)
  * with a priority of LOG_ERR.
  * Overrides the quiet mode during startup.
  */
+void vAlert(const char *fmt, va_list argp)
+{
+       __Alert(1, fmt, argp);
+}
+
+/*
+ * Displays the message on stderr with the date and pid.
+ * Also logs the same message using the prevailing logger, if any,
+ * with a priority of LOG_ERR.
+ * Overrides the quiet mode during startup.
+ */
 void Alert(const char *fmt, ...)
 {
        va_list argp;
@@ -116,27 +127,37 @@ static void Alert_no_send_log(const char *fmt, ...)
 /*
  * Displays the message on stderr with the date and pid.
  */
-void Warning(const char *fmt, ...)
+void vWarning(const char *fmt, va_list argp)
 {
-       va_list argp;
+       va_list argp2;
        struct tm tm;
 
        if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) {
-               va_start(argp, fmt);
-               vsend_log(NULL, LOG_WARNING, fmt, argp);
-               va_end(argp);
+               va_copy(argp2, argp);
+               vsend_log(NULL, LOG_WARNING, fmt, argp2);
+               va_end(argp2);
 
-               va_start(argp, fmt);
                get_localtime(date.tv_sec, &tm);
                fprintf(stderr, "[WARNING] %03d/%02d%02d%02d (%d) : ",
                        tm.tm_yday, tm.tm_hour, tm.tm_min, tm.tm_sec, 
(int)getpid());
                vfprintf(stderr, fmt, argp);
                fflush(stderr);
-               va_end(argp);
        }
 }
 
 /*
+ * Displays the message on stderr with the date and pid.
+ */
+void Warning(const char *fmt, ...)
+{
+       va_list argp;
+
+       va_start(argp, fmt);
+       vWarning(fmt, argp);
+       va_end(argp);
+}
+
+/*
  * Displays the message on <out> only if quiet mode is not set.
  */
 void qfprintf(FILE *out, const char *fmt, ...)
-- 
1.7.2.3


Reply via email to