dc3cc4c09487df8f61c0407ac3f05cdb82ba3130
[tpg/opendispense2.git] / src / server / logging.c
1 /*
2  * OpenDispense2
3  *
4  * logging.c - Debug/Logging Routines
5  */
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <stdarg.h>
9 #include <stdbool.h>
10 #include "common.h"
11 #include <syslog.h>
12
13 // === GLOBALS ===
14 bool    gbSyslogEnabled = true;
15
16 // === CODE ==
17 void Log_Error(const char *Format, ...)
18 {
19         va_list args;
20
21         va_start(args, Format);
22         if( gbSyslogEnabled )
23         {
24                 vsyslog(LOG_WARNING, Format, args);
25         }
26         else
27         {
28                 fprintf(stderr, "WARNING: ");
29                 vfprintf(stderr, Format, args);
30                 fprintf(stderr, "\n");
31         }
32         va_end(args);
33 }
34
35 void Log_Info(const char *Format, ...)
36 {
37         va_list args;
38         
39         va_start(args, Format);
40         if( gbSyslogEnabled )
41         {
42                 vsyslog(LOG_INFO, Format, args);
43         }
44         else
45         {
46                 fprintf(stderr, "WARNING: ");
47                 vfprintf(stderr, Format, args);
48                 fprintf(stderr, "\n");
49         }
50         va_end(args);
51 }
52

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