blob: c8f9f7e61d99fad76c8d7b285b36ed4c621c9af7 (
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
52
53
54
55
|
/* sysdep_syslog.c - Logging via syslog
*
* Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi>
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 or later as
* published by the Free Software Foundation.
*
* See http://www.gnu.org/ for 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));
}
|