]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/syslog.h
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1982, 1986, 1988, 1993
33 * The Regents of the University of California. All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * @(#)syslog.h 8.1 (Berkeley) 6/2/93
66 #ifndef _SYS_SYSLOG_H_
67 #define _SYS_SYSLOG_H_
69 #include <sys/appleapiopts.h>
70 #include <sys/cdefs.h>
72 #define _PATH_LOG "/var/run/syslog"
75 * priorities/facilities are encoded into a single 32-bit quantity, where the
76 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
77 * (0-big number). Both the priorities and the facilities map roughly
78 * one-to-one to strings in the syslogd(8) source code. This mapping is
79 * included in this file.
81 * priorities (these are ordered)
83 #define LOG_EMERG 0 /* system is unusable */
84 #define LOG_ALERT 1 /* action must be taken immediately */
85 #define LOG_CRIT 2 /* critical conditions */
86 #define LOG_ERR 3 /* error conditions */
87 #define LOG_WARNING 4 /* warning conditions */
88 #define LOG_NOTICE 5 /* normal but significant condition */
89 #define LOG_INFO 6 /* informational */
90 #define LOG_DEBUG 7 /* debug-level messages */
92 #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
93 /* extract priority */
94 #define LOG_PRI(p) ((p) & LOG_PRIMASK)
95 #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
98 #define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
100 #define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0)
101 typedef struct _code
{
106 CODE prioritynames
[] = {
107 { "alert", LOG_ALERT
},
108 { "crit", LOG_CRIT
},
109 { "debug", LOG_DEBUG
},
110 { "emerg", LOG_EMERG
},
112 { "error", LOG_ERR
}, /* DEPRECATED */
113 { "info", LOG_INFO
},
114 { "none", INTERNAL_NOPRI
}, /* INTERNAL */
115 { "notice", LOG_NOTICE
},
116 { "panic", LOG_EMERG
}, /* DEPRECATED */
117 { "warn", LOG_WARNING
}, /* DEPRECATED */
118 { "warning", LOG_WARNING
},
124 #define LOG_KERN (0<<3) /* kernel messages */
125 #define LOG_USER (1<<3) /* random user-level messages */
126 #define LOG_MAIL (2<<3) /* mail system */
127 #define LOG_DAEMON (3<<3) /* system daemons */
128 #define LOG_AUTH (4<<3) /* security/authorization messages */
129 #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
130 #define LOG_LPR (6<<3) /* line printer subsystem */
131 #define LOG_NEWS (7<<3) /* network news subsystem */
132 #define LOG_UUCP (8<<3) /* UUCP subsystem */
133 #define LOG_CRON (9<<3) /* clock daemon */
134 #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
135 #define LOG_FTP (11<<3) /* ftp daemon */
136 #define LOG_NETINFO (12<<3) /* NetInfo */
137 #define LOG_REMOTEAUTH (13<<3) /* remote authentication/authorization */
138 #define LOG_INSTALL (14<<3) /* installer subsystem */
139 #define LOG_RAS (15<<3) /* Remote Access Service (VPN / PPP) */
141 #define LOG_LOCAL0 (16<<3) /* reserved for local use */
142 #define LOG_LOCAL1 (17<<3) /* reserved for local use */
143 #define LOG_LOCAL2 (18<<3) /* reserved for local use */
144 #define LOG_LOCAL3 (19<<3) /* reserved for local use */
145 #define LOG_LOCAL4 (20<<3) /* reserved for local use */
146 #define LOG_LOCAL5 (21<<3) /* reserved for local use */
147 #define LOG_LOCAL6 (22<<3) /* reserved for local use */
148 #define LOG_LOCAL7 (23<<3) /* reserved for local use */
150 #define LOG_LAUNCHD (24<<3) /* launchd - general bootstrap daemon */
152 #define LOG_NFACILITIES 25 /* current number of facilities */
153 #define LOG_FACMASK 0x03f8 /* mask to extract facility part */
154 /* facility of pri */
155 #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
158 CODE facilitynames
[] = {
159 { "auth", LOG_AUTH
},
160 { "authpriv", LOG_AUTHPRIV
},
161 { "cron", LOG_CRON
},
162 { "daemon", LOG_DAEMON
},
164 { "install", LOG_INSTALL
},
165 { "kern", LOG_KERN
},
167 { "mail", LOG_MAIL
},
168 { "mark", INTERNAL_MARK
}, /* INTERNAL */
169 { "netinfo", LOG_NETINFO
},
171 { "remoteauth", LOG_REMOTEAUTH
},
172 { "news", LOG_NEWS
},
173 { "security", LOG_AUTH
}, /* DEPRECATED */
174 { "syslog", LOG_SYSLOG
},
175 { "user", LOG_USER
},
176 { "uucp", LOG_UUCP
},
177 { "local0", LOG_LOCAL0
},
178 { "local1", LOG_LOCAL1
},
179 { "local2", LOG_LOCAL2
},
180 { "local3", LOG_LOCAL3
},
181 { "local4", LOG_LOCAL4
},
182 { "local5", LOG_LOCAL5
},
183 { "local6", LOG_LOCAL6
},
184 { "local7", LOG_LOCAL7
},
185 { "launchd", LOG_LAUNCHD
},
191 #ifdef __APPLE_API_PRIVATE
192 #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */
193 #endif /* __APPLE_API_PRIVATE */
197 * arguments to setlogmask.
199 #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
200 #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
203 * Option flags for openlog.
205 * LOG_ODELAY no longer does anything.
206 * LOG_NDELAY is the inverse of what it used to be.
208 #define LOG_PID 0x01 /* log the pid with each message */
209 #define LOG_CONS 0x02 /* log on the console if errors in sending */
210 #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
211 #define LOG_NDELAY 0x08 /* don't delay open */
212 #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
213 #define LOG_PERROR 0x20 /* log to stderr as well */
216 #ifndef _POSIX_C_SOURCE
217 #include <sys/_types.h> /* for __darwin_va_list */
218 #endif /* _POSIX_C_SOURCE */
222 void openlog(const char *, int, int);
224 void syslog(int, const char *, ...) __DARWIN_LDBL_COMPAT(syslog
);
225 #ifndef _POSIX_C_SOURCE
226 void vsyslog(int, const char *, __darwin_va_list
) __DARWIN_LDBL_COMPAT(vsyslog
);
227 #endif /* _POSIX_C_SOURCE */
231 #ifdef __APPLE_API_OBSOLETE
233 * bit field descriptions for printf %r and %R formats
237 * printf("%r %R", val, reg_descp);
238 * struct reg_desc *reg_descp;
240 * the %r and %R formats allow formatted output of bit fields.
241 * reg_descp points to an array of reg_desc structures, each element of the
242 * array describes a range of bits within val. the array should have a
243 * final element with all structure elements 0.
244 * %r outputs a string of the format "<bit field descriptions>"
245 * %R outputs a string of the format "0x%x<bit field descriptions>"
247 * The fields in a reg_desc are:
248 * unsigned rd_mask; An appropriate mask to isolate the bit field
249 * within a word, and'ed with val
251 * int rd_shift; A shift amount to be done to the isolated
252 * bit field. done before printing the isolate
253 * bit field with rd_format and before searching
254 * for symbolic value names in rd_values
256 * char *rd_name; If non-null, a bit field name to label any
257 * out from rd_format or searching rd_values.
258 * if neither rd_format or rd_values is non-null
259 * rd_name is printed only if the isolated
260 * bit field is non-null.
262 * char *rd_format; If non-null, the shifted bit field value
263 * is printed using this format.
265 * struct reg_values *rd_values; If non-null, a pointer to a table
266 * matching numeric values with symbolic names.
267 * rd_values are searched and the symbolic
268 * value is printed if a match is found, if no
269 * match is found "???" is printed.
271 * printf("%n %N", val, reg_valuesp);
272 * struct reg_values *reg_valuesp;
274 * the %n and %N formats allow formatted output of symbolic constants
275 * Reg_valuesp is a pointer to an array of struct reg_values which pairs
276 * numeric values (rv_value) with symbolic names (rv_name). The array is
277 * terminated with a reg_values entry that has a null pointer for the
278 * rv_name field. When %n or %N is used rd_values are searched and the
279 * symbolic value is printed if a match is found, if no match is found
285 * the %C format prints an int as a 4 character string.
286 * The most significant byte of the int is printed first, the least
287 * significant byte is printed last.
292 * map between numeric values and symbolic values
300 * register descriptors are used for formatted prints of register values
301 * rd_mask and rd_shift must be defined, other entries may be null
304 unsigned rd_mask
; /* mask to extract field */
305 int rd_shift
; /* shift for extracted value, - >>, + << */
306 char *rd_name
; /* field name */
307 char *rd_format
; /* format to print field */
308 struct reg_values
*rd_values
; /* symbolic names of values */
311 #endif /* __APPLE_API_OBSOLETE */
315 void log(int, const char *, ...);
316 void addlog(const char *, ...);
320 #endif /* !_SYS_SYSLOG_H_ */