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