Skip to content
Snippets Groups Projects
Commit 351184b3 authored by John Hodge's avatar John Hodge
Browse files

Allow logging to be disabled, rename 'add' account

parent 5052045f
Branches
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -6,16 +6,29 @@
#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);
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);
}
......@@ -9,6 +9,7 @@
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <signal.h>
#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);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment