Diffstat (limited to 'noncore/net/wellenreiter/daemon/source/log.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/log.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/log.cc b/noncore/net/wellenreiter/daemon/source/log.cc new file mode 100644 index 0000000..47589d2 --- a/dev/null +++ b/noncore/net/wellenreiter/daemon/source/log.cc | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Small functions to log to syslog | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "config.hh" | ||
8 | #include "log.hh" | ||
9 | |||
10 | /* Log to syslog INFO */ | ||
11 | void log_info(const char *fmt,...) | ||
12 | { | ||
13 | |||
14 | char buffer[4096]; | ||
15 | va_list ap; | ||
16 | |||
17 | memset(buffer, 0, sizeof(buffer)), | ||
18 | va_start(ap, fmt); | ||
19 | vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); | ||
20 | va_end(ap); | ||
21 | |||
22 | openlog(PROGNAME, LOG_PID, LOG_SYSLOG); | ||
23 | syslog(LOG_INFO, "(info) %s", buffer); | ||
24 | closelog(); | ||
25 | |||
26 | #ifdef DEBUG | ||
27 | fprintf(stderr, "(info) %s\n", buffer); | ||
28 | #endif | ||
29 | |||
30 | } | ||
31 | |||
32 | /* Log to syslog ERR */ | ||
33 | void log_err(const char *fmt,...) | ||
34 | { | ||
35 | |||
36 | char buffer[4096]; | ||
37 | va_list ap; | ||
38 | |||
39 | memset(buffer, 0, sizeof(buffer)); | ||
40 | va_start(ap, fmt); | ||
41 | vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); | ||
42 | va_end(ap); | ||
43 | |||
44 | openlog(PROGNAME, LOG_PID, LOG_SYSLOG); | ||
45 | syslog(LOG_INFO, "(err) %s", buffer); | ||
46 | closelog(); | ||
47 | |||
48 | #ifdef DEBUG | ||
49 | fprintf(stderr, "(err) %s\n", buffer); | ||
50 | #endif | ||
51 | |||
52 | } | ||