xref: /freebsd/usr.sbin/bluetooth/sdpd/log.c (revision c697fb7f)
1 /*-
2  * log.c
3  *
4  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5  *
6  * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@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 2004/01/07 23:15:00 max Exp $
31  * $FreeBSD$
32  */
33 
34 #include <sys/types.h>
35 #include <stdarg.h>
36 #include <syslog.h>
37 
38 void
39 log_open(char const *prog, int32_t log2stderr)
40 {
41 	openlog(prog, LOG_PID|LOG_NDELAY|(log2stderr? LOG_PERROR:0), LOG_USER);
42 }
43 
44 void
45 log_close(void)
46 {
47 	closelog();
48 }
49 
50 void
51 log_emerg(char const *message, ...)
52 {
53 	va_list	ap;
54 
55 	va_start(ap, message);
56 	vsyslog(LOG_EMERG, message, ap);
57 	va_end(ap);
58 }
59 
60 void
61 log_alert(char const *message, ...)
62 {
63 	va_list	ap;
64 
65 	va_start(ap, message);
66 	vsyslog(LOG_ALERT, message, ap);
67 	va_end(ap);
68 }
69 
70 void
71 log_crit(char const *message, ...)
72 {
73 	va_list	ap;
74 
75 	va_start(ap, message);
76 	vsyslog(LOG_CRIT, message, ap);
77 	va_end(ap);
78 }
79 
80 void
81 log_err(char const *message, ...)
82 {
83 	va_list	ap;
84 
85 	va_start(ap, message);
86 	vsyslog(LOG_ERR, message, ap);
87 	va_end(ap);
88 }
89 
90 void
91 log_warning(char const *message, ...)
92 {
93 	va_list	ap;
94 
95 	va_start(ap, message);
96 	vsyslog(LOG_WARNING, message, ap);
97 	va_end(ap);
98 }
99 
100 void
101 log_notice(char const *message, ...)
102 {
103 	va_list	ap;
104 
105 	va_start(ap, message);
106 	vsyslog(LOG_NOTICE, message, ap);
107 	va_end(ap);
108 }
109 
110 void
111 log_info(char const *message, ...)
112 {
113 	va_list	ap;
114 
115 	va_start(ap, message);
116 	vsyslog(LOG_INFO, message, ap);
117 	va_end(ap);
118 }
119 
120 void
121 log_debug(char const *message, ...)
122 {
123 	va_list	ap;
124 
125 	va_start(ap, message);
126 	vsyslog(LOG_DEBUG, message, ap);
127 	va_end(ap);
128 }
129 
130