]> git.ipfire.org Git - fireperf.git/commitdiff
logging: Revert to log to console
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Jan 2021 17:01:34 +0000 (17:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Jan 2021 17:01:34 +0000 (17:01 +0000)
This is easier for debugging

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/logging.c

index 476e63db9fffa0af49fb6b29e26c4a595ccd59ce..fd287d2aef58221d8e312663d59e8271a1c062f0 100644 (file)
@@ -19,6 +19,7 @@
 #############################################################################*/
 
 #include <stdarg.h>
+#include <stdio.h>
 #include <syslog.h>
 
 #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);
 }