From 3137deb496e4bfa80d55d33c81b54d7a7a3c4cee Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Mon, 2 Oct 2023 13:18:39 -0500 Subject: server: log function should also write to stderr The logging API should write to both the specified file handle and stderr. This allows the init system (if there is one in use) to also write messages to its internal buffer. Signed-off-by: Danny Holman --- server/src/logging.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/logging.c b/server/src/logging.c index e295116..6adaf51 100644 --- a/server/src/logging.c +++ b/server/src/logging.c @@ -26,12 +26,12 @@ int vlog_msg(int level, const char *fmt, va_list args) { case LOG_SEVERE: snprintf(output, 1024, "%s %s: %s", timestr, severe, fmt); ret = vfprintf(out_stream, output, args); - vfprintf(stderr, output, args); + vfprintf(out_stream, output, args); break; case LOG_WARNING: snprintf(output, 1024, "%s %s: %s", timestr, warn, fmt); ret = vfprintf(out_stream, output, args); - vfprintf(stderr, output, args); + vfprintf(out_stream, output, args); break; case LOG_INFO: snprintf(output, 1024, "%s %s: %s", timestr, info, fmt); @@ -54,6 +54,10 @@ int log_msg(int level, const char *fmt, ...) { done = vlog_msg(level, fmt, args); va_end(args); + va_start(args, fmt); + done = vfprintf(stderr, fmt, args); + va_end(args); + return done; } -- cgit v1.2.3