diff --git a/src/log.c b/src/log.c index 1a7626e..9250f2d 100644 --- a/src/log.c +++ b/src/log.c @@ -34,6 +34,7 @@ static struct { void *udata; log_LockFn lock; int level; + int level_stderr; bool quiet; Callback callbacks[MAX_CALLBACKS]; } L; @@ -106,6 +107,9 @@ void log_set_level(int level) { L.level = level; } +void log_set_level_stderr(int level) { + L.level_stderr = level; +} void log_set_quiet(bool enable) { L.quiet = enable; @@ -148,7 +152,7 @@ void log_log(int level, const char *file, int line, const char *fmt, ...) { lock(); if (!L.quiet && level >= L.level) { - init_event(&ev, stderr); + init_event(&ev, level >= L.level_stderr ? stderr : stdout); va_start(ev.ap, fmt); stdout_callback(&ev); va_end(ev.ap); diff --git a/src/log.h b/src/log.h index b1fae24..7ca91bf 100644 --- a/src/log.h +++ b/src/log.h @@ -40,6 +40,7 @@ enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL }; const char* log_level_string(int level); void log_set_lock(log_LockFn fn, void *udata); void log_set_level(int level); +void log_set_level_stderr(int level); void log_set_quiet(bool enable); int log_add_callback(log_LogFn fn, void *udata, int level); int log_add_fp(FILE *fp, int level);