forked from dancrossnyc/44ripd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlog.c
64 lines (56 loc) · 849 Bytes
/
log.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdarg.h>
#include <syslog.h>
#include <stdlib.h>
#include "log.h"
void
initlog(void)
{
openlog("44ripd", LOG_CONS | LOG_PERROR | LOG_PID, LOG_LOCAL0);
}
void
debug(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsyslog(LOG_DEBUG, fmt, ap);
va_end(ap);
}
void
info(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsyslog(LOG_INFO, fmt, ap);
va_end(ap);
}
void
notice(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsyslog(LOG_NOTICE, fmt, ap);
va_end(ap);
}
void
error(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsyslog(LOG_WARNING, fmt, ap);
va_end(ap);
}
void
fatal(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsyslog(LOG_ERR, fmt, ap);
va_end(ap);
exit(EXIT_FAILURE);
}
void
fatal_err(const char *msg)
{
syslog(LOG_ERR, "%s: %m", msg);
exit(EXIT_FAILURE);
}