Server - Fix inverted logic in enabling/disabling syslog
[tpg/opendispense2.git] / src / server / logging.c
index d7313c9..2ef0e12 100644 (file)
@@ -6,16 +6,29 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include "common.h"
 #include <syslog.h>
 
+// === GLOBALS ===
+bool   gbSyslogDisabled = true;
+
 // === CODE ==
 void Log_Error(const char *Format, ...)
 {
        va_list args;
 
+       if( !gbSyslogDisabled )
+       {
+               va_start(args, Format);
+               vsyslog(LOG_WARNING, Format, args);
+               va_end(args);
+       }
+       
        va_start(args, Format);
-       vsyslog(LOG_WARNING, Format, args);
+       fprintf(stderr, "WARNING: ");
+       vfprintf(stderr, Format, args);
+       fprintf(stderr, "\n");
        va_end(args);
 }
 
@@ -23,8 +36,16 @@ void Log_Info(const char *Format, ...)
 {
        va_list args;
        
+       if( !gbSyslogDisabled )
+       {
+               va_start(args, Format);
+               vsyslog(LOG_INFO, Format, args);
+               va_end(args);
+       }
        va_start(args, Format);
-       vsyslog(LOG_INFO, Format, args);
+       fprintf(stderr, "INFO: ");
+       vfprintf(stderr, Format, args);
+       fprintf(stderr, "\n");
        va_end(args);
 }
 

UCC git Repository :: git.ucc.asn.au