Allow logging to be disabled, rename 'add' account
[tpg/opendispense2.git] / src / server / logging.c
index 51cc8d2..dc3cc4c 100644 (file)
@@ -5,15 +5,48 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdarg.h>
+#include <stdbool.h>
 #include "common.h"
+#include <syslog.h>
+
+// === GLOBALS ===
+bool   gbSyslogEnabled = true;
 
 // === CODE ==
 void Log_Error(const char *Format, ...)
 {
-       
+       va_list args;
+
+       va_start(args, Format);
+       if( gbSyslogEnabled )
+       {
+               vsyslog(LOG_WARNING, Format, args);
+       }
+       else
+       {
+               fprintf(stderr, "WARNING: ");
+               vfprintf(stderr, Format, args);
+               fprintf(stderr, "\n");
+       }
+       va_end(args);
 }
 
 void Log_Info(const char *Format, ...)
 {
+       va_list args;
+       
+       va_start(args, Format);
+       if( gbSyslogEnabled )
+       {
+               vsyslog(LOG_INFO, Format, args);
+       }
+       else
+       {
+               fprintf(stderr, "WARNING: ");
+               vfprintf(stderr, Format, args);
+               fprintf(stderr, "\n");
+       }
+       va_end(args);
 }
 

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