From: John Hodge Date: Fri, 21 Mar 2014 14:55:25 +0000 (+0800) Subject: Allow logging to be disabled, rename 'add' account X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=351184b3a2b597193234d09090281b8501f659c6;p=tpg%2Fopendispense2.git Allow logging to be disabled, rename 'add' account --- diff --git a/dispsrv.conf b/dispsrv.conf index 2043708..ae1d954 100644 --- a/dispsrv.conf +++ b/dispsrv.conf @@ -14,6 +14,8 @@ coke_modbus_address 0.0.0.0 test_mode no #test_mode yes +disable_syslog yes + # Used to set dispense into a dummy mode when the coke machine is out of action # and we're dispensing drinks from the fridge (or manually) coke_dummy_mode no diff --git a/src/cokebank.h b/src/cokebank.h index 1ea8120..1328c11 100644 --- a/src/cokebank.h +++ b/src/cokebank.h @@ -18,7 +18,7 @@ #define COKEBANK_SALES_ACCT ">sales" //!< Sales made into #define COKEBANK_SALES_PREFIX ">sales:" //!< Sales made into -#define COKEBANK_ADDSRC_ACCT ">delta" //!< Credit taken out of +#define COKEBANK_ADDSRC_ACCT ">additions" //!< Credit taken out of #define COKEBANK_DEBT_ACCT ">countersum" //!< Balancing account (causes sum to be 0) #define COKEBANK_FREE_ACCT ">freeitems" //!< ODay drink costs taken out of #define COKEBANK_DONATE_ACCT ">donations" //!< Donations go here diff --git a/src/server/logging.c b/src/server/logging.c index d7313c9..dc3cc4c 100644 --- a/src/server/logging.c +++ b/src/server/logging.c @@ -6,16 +6,29 @@ #include #include #include +#include #include "common.h" #include +// === GLOBALS === +bool gbSyslogEnabled = true; + // === CODE == void Log_Error(const char *Format, ...) { va_list args; va_start(args, Format); - vsyslog(LOG_WARNING, Format, args); + if( gbSyslogEnabled ) + { + vsyslog(LOG_WARNING, Format, args); + } + else + { + fprintf(stderr, "WARNING: "); + vfprintf(stderr, Format, args); + fprintf(stderr, "\n"); + } va_end(args); } @@ -24,7 +37,16 @@ void Log_Info(const char *Format, ...) va_list args; va_start(args, Format); - vsyslog(LOG_INFO, Format, args); + if( gbSyslogEnabled ) + { + vsyslog(LOG_INFO, Format, args); + } + else + { + fprintf(stderr, "WARNING: "); + vfprintf(stderr, Format, args); + fprintf(stderr, "\n"); + } va_end(args); } diff --git a/src/server/main.c b/src/server/main.c index 247533e..284002b 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include "common.h" @@ -30,6 +31,7 @@ extern int giServer_Port; extern const char *gsItemListFile; extern const char *gsCoke_ModbusAddress; extern const char *gsDoor_SerialPort; +extern bool gbSyslogEnabled; // === PROTOTYPES === void *Periodic_Thread(void *Unused); @@ -128,6 +130,7 @@ int main(int argc, char *argv[]) gsItemListFile = Config_GetValue("items_file", 0); gbNoCostMode = (Config_GetValue_Bool("test_mode", 0) == 1); + gbSyslogEnabled = (Config_GetValue_Bool("disable_syslog", 0) == 0); signal(SIGINT, sigint_handler); signal(SIGTERM, sigint_handler);