From: Michael Tremer Date: Mon, 25 Jan 2021 17:01:34 +0000 (+0000) Subject: logging: Revert to log to console X-Git-Tag: 0.1.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1222dbc39936e6dd8f477c839763d0152615a314;p=fireperf.git logging: Revert to log to console This is easier for debugging Signed-off-by: Michael Tremer --- diff --git a/src/logging.c b/src/logging.c index 476e63d..fd287d2 100644 --- a/src/logging.c +++ b/src/logging.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include #include "logging.h" @@ -28,10 +29,19 @@ int fireperf_get_log_level(struct fireperf_config* conf) { return conf->loglevel; } -static void fireperf_log_syslog(struct fireperf_config* conf, int priority, +static void fireperf_log_console(struct fireperf_config* conf, int priority, const char* file, int line, const char* fn, const char* format, va_list args) { - openlog(PACKAGE_NAME, LOG_PID, LOG_DAEMON); - vsyslog(priority | LOG_DAEMON, format, args); + switch (priority) { + // Print error messages to stderr + case LOG_ERR: + vfprintf(stderr, format, args); + break; + + // Otherwise print to stdout + default: + vprintf(format, args); + break; + } } void fireperf_log(struct fireperf_config* conf, int priority, @@ -39,6 +49,6 @@ void fireperf_log(struct fireperf_config* conf, int priority, va_list args; va_start(args, format); - fireperf_log_syslog(conf, priority, file, line, fn, format, args); + fireperf_log_console(conf, priority, file, line, fn, format, args); va_end(args); }