From: John Hodge Date: Thu, 16 Apr 2015 06:16:59 +0000 (+0800) Subject: Server - Fix inverted logic in enabling/disabling syslog X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=73c9293948d3823d7d63f7f4b2ae73bd11ae33a0;p=tpg%2Fopendispense2.git Server - Fix inverted logic in enabling/disabling syslog --- diff --git a/src/server/common.h b/src/server/common.h index 34ae298..f1304db 100644 --- a/src/server/common.h +++ b/src/server/common.h @@ -73,6 +73,8 @@ extern int giNumHandlers; extern int giDebugLevel; extern bool gbNoCostMode; +extern bool gbSyslogDisabled; + // === FUNCTIONS === extern void Items_UpdateFile(void); diff --git a/src/server/logging.c b/src/server/logging.c index dc3cc4c..2ef0e12 100644 --- a/src/server/logging.c +++ b/src/server/logging.c @@ -11,24 +11,24 @@ #include // === 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); } diff --git a/src/server/main.c b/src/server/main.c index 3e06230..2e1985d 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -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");