From a41e9f8c8c5d7c379389dfa497c0470849aa74de Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 5 Feb 2013 17:36:09 +0100 Subject: [PATCH] Print messages with level below LOG_NOTICE to stderr. Signed-off-by: Miroslav Lichvar --- print.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/print.c b/print.c index 7c21902..a82d0e7 100644 --- a/print.c +++ b/print.c @@ -54,6 +54,7 @@ void print(int level, char const *format, ...) struct timespec ts; va_list ap; char buf[1024]; + FILE *f; if (level > print_level) return; @@ -65,10 +66,11 @@ void print(int level, char const *format, ...) va_end(ap); if (verbose) { - fprintf(stdout, "%s[%ld.%03ld]: %s\n", + f = level >= LOG_NOTICE ? stdout : stderr; + fprintf(f, "%s[%ld.%03ld]: %s\n", progname ? progname : "", ts.tv_sec, ts.tv_nsec / 1000000, buf); - fflush(stdout); + fflush(f); } if (use_syslog) { syslog(level, "[%ld.%03ld] %s",