log.c revision 1.1 1 /* $NetBSD: log.c,v 1.1 2006/06/19 15:44:56 gdamore Exp $ */
2
3 /*
4 * log.c
5 *
6 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin (at) yahoo.com>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $Id: log.c,v 1.1 2006/06/19 15:44:56 gdamore Exp $
31 * $FreeBSD: src/usr.sbin/bluetooth/sdpd/log.c,v 1.1 2004/01/20 20:48:26 emax Exp $
32 */
33
34 #include <sys/cdefs.h>
35 __RCSID("$NetBSD: log.c,v 1.1 2006/06/19 15:44:56 gdamore Exp $");
36
37 #include <sys/types.h>
38 #include <stdarg.h>
39 #include <syslog.h>
40
41 #include "log.h"
42
43 void
44 log_open(char const *prog, int32_t log2stderr)
45 {
46 openlog(prog, LOG_PID|LOG_NDELAY|(log2stderr? LOG_PERROR:0), LOG_USER);
47 }
48
49 void
50 log_close(void)
51 {
52 closelog();
53 }
54
55 void
56 log_emerg(char const *message, ...)
57 {
58 va_list ap;
59
60 va_start(ap, message);
61 vsyslog(LOG_EMERG, message, ap);
62 va_end(ap);
63 }
64
65 void
66 log_alert(char const *message, ...)
67 {
68 va_list ap;
69
70 va_start(ap, message);
71 vsyslog(LOG_ALERT, message, ap);
72 va_end(ap);
73 }
74
75 void
76 log_crit(char const *message, ...)
77 {
78 va_list ap;
79
80 va_start(ap, message);
81 vsyslog(LOG_CRIT, message, ap);
82 va_end(ap);
83 }
84
85 void
86 log_err(char const *message, ...)
87 {
88 va_list ap;
89
90 va_start(ap, message);
91 vsyslog(LOG_ERR, message, ap);
92 va_end(ap);
93 }
94
95 void
96 log_warning(char const *message, ...)
97 {
98 va_list ap;
99
100 va_start(ap, message);
101 vsyslog(LOG_WARNING, message, ap);
102 va_end(ap);
103 }
104
105 void
106 log_notice(char const *message, ...)
107 {
108 va_list ap;
109
110 va_start(ap, message);
111 vsyslog(LOG_NOTICE, message, ap);
112 va_end(ap);
113 }
114
115 void
116 log_info(char const *message, ...)
117 {
118 va_list ap;
119
120 va_start(ap, message);
121 vsyslog(LOG_INFO, message, ap);
122 va_end(ap);
123 }
124
125 void
126 log_debug(char const *message, ...)
127 {
128 va_list ap;
129
130 va_start(ap, message);
131 vsyslog(LOG_DEBUG, message, ap);
132 va_end(ap);
133 }
134