Server - Fix inverted logic in enabling/disabling syslog
authorJohn Hodge <[email protected]>
Thu, 16 Apr 2015 06:16:59 +0000 (14:16 +0800)
committerJohn Hodge <[email protected]>
Thu, 16 Apr 2015 06:16:59 +0000 (14:16 +0800)
src/server/common.h
src/server/logging.c
src/server/main.c

index 34ae298..f1304db 100644 (file)
@@ -73,6 +73,8 @@ extern int    giNumHandlers;
 extern int     giDebugLevel;
 extern bool    gbNoCostMode;
 
+extern bool    gbSyslogDisabled;
+
 // === FUNCTIONS ===
 extern void    Items_UpdateFile(void);
 
index dc3cc4c..2ef0e12 100644 (file)
 #include <syslog.h>
 
 // === GLOBALS ===
-bool   gbSyslogEnabled = true;
+bool   gbSyslogDisabled = true;
 
 // === CODE ==
 void Log_Error(const char *Format, ...)
 {
        va_list args;
 
-       va_start(args, Format);
-       if( gbSyslogEnabled )
+       if( !gbSyslogDisabled )
        {
+               va_start(args, Format);
                vsyslog(LOG_WARNING, Format, args);
+               va_end(args);
        }
-       else
-       {
-               fprintf(stderr, "WARNING: ");
-               vfprintf(stderr, Format, args);
-               fprintf(stderr, "\n");
-       }
+       
+       va_start(args, Format);
+       fprintf(stderr, "WARNING: ");
+       vfprintf(stderr, Format, args);
+       fprintf(stderr, "\n");
        va_end(args);
 }
 
@@ -36,17 +36,16 @@ void Log_Info(const char *Format, ...)
 {
        va_list args;
        
-       va_start(args, Format);
-       if( gbSyslogEnabled )
+       if( !gbSyslogDisabled )
        {
+               va_start(args, Format);
                vsyslog(LOG_INFO, Format, args);
+               va_end(args);
        }
-       else
-       {
-               fprintf(stderr, "WARNING: ");
-               vfprintf(stderr, Format, args);
-               fprintf(stderr, "\n");
-       }
+       va_start(args, Format);
+       fprintf(stderr, "INFO: ");
+       vfprintf(stderr, Format, args);
+       fprintf(stderr, "\n");
        va_end(args);
 }
 
index 3e06230..2e1985d 100644 (file)
@@ -33,7 +33,6 @@ extern const char     *gsItemListFile;
 extern const char      *gsCoke_ModbusAddress;
 extern int     giCoke_ModbusPort;
 extern const char      *gsDoor_SerialPort;
-extern bool    gbSyslogEnabled;
 
 // === PROTOTYPES ===
 void   *Periodic_Thread(void *Unused);
@@ -144,7 +143,7 @@ int main(int argc, char *argv[])
                OPT_CFG(giCoke_ModbusPort,    Int,    "coke_modbus_port");
                
                OPT_CFG(gbNoCostMode,    Bool, "test_mode");
-               OPT_CFG(gbSyslogEnabled, Bool, "disable_syslog");
+               OPT_CFG(gbSyslogDisabled, Bool, "disable_syslog");
                
                if( !rv ) {
                        fprintf(stderr, "ERROR: Some required configuration items were missing\n");

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