From 09091abdda7df60d6ef67921a427067ff92bb782 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Mon, 7 Nov 2011 22:18:20 +0000 Subject: [PATCH] default log level: info warn/err printed to stderr info printed to stdout --- src/lib/log.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/log.c b/src/lib/log.c index fdae032..f5eb282 100644 --- a/src/lib/log.c +++ b/src/lib/log.c @@ -28,7 +28,7 @@ #include "log.h" static FILE *file; -int log_level = LOG_WARN; +int log_level = LOG_INFO; void log_open(const char *path) { @@ -57,6 +57,7 @@ void log_printf(int lvl, const char *fmt, ...) char buffer[1 + LOG_BUFFER]; va_list ap; char *lvl_str; + FILE *stdf; if (lvl > LOG_INFO && (!file || lvl > log_level)) return ; @@ -91,6 +92,12 @@ void log_printf(int lvl, const char *fmt, ...) fflush(file); } - if (lvl <= LOG_INFO) - printf("[%ld] %s %s\n", tv.tv_sec, lvl_str, buffer); + if (lvl <= LOG_INFO) { + if (lvl == LOG_WARN || lvl == LOG_ERR) + stdf = stderr; + else + stdf = stdout; + + fprintf(stdf, "[%ld] %s %s\n", tv.tv_sec, lvl_str, buffer); + } } -- 2.7.4