blob: 3004be870a21ec0a78bd3e13f907e4cfcf3f0f60 (
plain)
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
|
/* sysdep_syslog.c - Logging via syslog
*
* Copyright (c) 2007-2012 Timo Teräs <timo.teras@iki.fi>
*
* This software is licensed under the MIT License.
* See MIT-LICENSE.txt for additional details.
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <stdarg.h>
#include "nhrp_defines.h"
#include "nhrp_common.h"
int log_init(void)
{
openlog("opennhrp", LOG_PERROR | LOG_PID, LOG_DAEMON);
return TRUE;
}
void nhrp_log(int level, const char *format, ...)
{
va_list va;
int l;
switch (level) {
case NHRP_LOG_ERROR:
l = LOG_ERR;
break;
case NHRP_LOG_INFO:
l = LOG_INFO;
break;
case NHRP_LOG_DEBUG:
default:
l = LOG_DEBUG;
break;
}
va_start(va, format);
vsyslog(l, format, va);
va_end(va);
}
void nhrp_perror(const char *message)
{
nhrp_error("%s: %s", message, strerror(errno));
}
|