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