xref: /original-bsd/sys/sys/syslog.h (revision e4dd4c49)
1 /*
2  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)syslog.h	7.15 (Berkeley) 11/13/89
18  */
19 
20 /*
21  * priorities/facilities are encoded into a single 32-bit quantity, where the
22  * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
23  * (0-big number).  Both the priorities and the facilities map roughly
24  * one-to-one to strings in the syslogd(8) source code.  This mapping is
25  * included in this file.
26  *
27  * priorities (these are ordered)
28  */
29 #define	LOG_EMERG	0	/* system is unusable */
30 #define	LOG_ALERT	1	/* action must be taken immediately */
31 #define	LOG_CRIT	2	/* critical conditions */
32 #define	LOG_ERR		3	/* error conditions */
33 #define	LOG_WARNING	4	/* warning conditions */
34 #define	LOG_NOTICE	5	/* normal but significant condition */
35 #define	LOG_INFO	6	/* informational */
36 #define	LOG_DEBUG	7	/* debug-level messages */
37 
38 #define	LOG_PRIMASK	0x07	/* mask to extract priority part (internal) */
39 				/* extract priority */
40 #define	LOG_PRI(p)	((p) & LOG_PRIMASK)
41 #define	LOG_MAKEPRI(fac, pri)	(((fac) << 3) | (pri))
42 
43 #ifdef SYSLOG_NAMES
44 #define	INTERNAL_NOPRI	0x10	/* the "no priority" priority */
45 				/* mark "facility" */
46 #define	INTERNAL_MARK	LOG_MAKEPRI(LOG_NFACILITIES, 0)
47 typedef struct _code {
48 	char	*c_name;
49 	int	c_val;
50 } CODE;
51 
52 CODE prioritynames[] = {
53 	"alert",	LOG_ALERT,
54 	"crit",		LOG_CRIT,
55 	"debug",	LOG_DEBUG,
56 	"emerg",	LOG_EMERG,
57 	"err",		LOG_ERR,
58 	"error",	LOG_ERR,		/* DEPRECATED */
59 	"info",		LOG_INFO,
60 	"none",		INTERNAL_NOPRI,		/* INTERNAL */
61 	"notice",	LOG_NOTICE,
62 	"panic", 	LOG_EMERG,		/* DEPRECATED */
63 	"warn",		LOG_WARNING,		/* DEPRECATED */
64 	"warning",	LOG_WARNING,
65 	NULL,		-1,
66 };
67 #endif
68 
69 /* facility codes */
70 #define	LOG_KERN	(0<<3)	/* kernel messages */
71 #define	LOG_USER	(1<<3)	/* random user-level messages */
72 #define	LOG_MAIL	(2<<3)	/* mail system */
73 #define	LOG_DAEMON	(3<<3)	/* system daemons */
74 #define	LOG_AUTH	(4<<3)	/* security/authorization messages */
75 #define	LOG_SYSLOG	(5<<3)	/* messages generated internally by syslogd */
76 #define	LOG_LPR		(6<<3)	/* line printer subsystem */
77 #define	LOG_NEWS	(7<<3)	/* network news subsystem */
78 #define	LOG_UUCP	(8<<3)	/* UUCP subsystem */
79 #define	LOG_CRON	(9<<3)	/* clock daemon */
80 	/* other codes through 15 reserved for system use */
81 #define	LOG_LOCAL0	(16<<3)	/* reserved for local use */
82 #define	LOG_LOCAL1	(17<<3)	/* reserved for local use */
83 #define	LOG_LOCAL2	(18<<3)	/* reserved for local use */
84 #define	LOG_LOCAL3	(19<<3)	/* reserved for local use */
85 #define	LOG_LOCAL4	(20<<3)	/* reserved for local use */
86 #define	LOG_LOCAL5	(21<<3)	/* reserved for local use */
87 #define	LOG_LOCAL6	(22<<3)	/* reserved for local use */
88 #define	LOG_LOCAL7	(23<<3)	/* reserved for local use */
89 
90 #define	LOG_NFACILITIES	24	/* current number of facilities */
91 #define	LOG_FACMASK	0x03f8	/* mask to extract facility part */
92 				/* facility of pri */
93 #define	LOG_FAC(p)	(((p) & LOG_FACMASK) >> 3)
94 
95 #ifdef SYSLOG_NAMES
96 CODE facilitynames[] = {
97 	"auth",		LOG_AUTH,
98 	"cron", 	LOG_CRON,
99 	"daemon",	LOG_DAEMON,
100 	"kern",		LOG_KERN,
101 	"lpr",		LOG_LPR,
102 	"mail",		LOG_MAIL,
103 	"mark", 	INTERNAL_MARK,		/* INTERNAL */
104 	"news",		LOG_NEWS,
105 	"security",	LOG_AUTH,		/* DEPRECATED */
106 	"syslog",	LOG_SYSLOG,
107 	"user",		LOG_USER,
108 	"uucp",		LOG_UUCP,
109 	"local0",	LOG_LOCAL0,
110 	"local1",	LOG_LOCAL1,
111 	"local2",	LOG_LOCAL2,
112 	"local3",	LOG_LOCAL3,
113 	"local4",	LOG_LOCAL4,
114 	"local5",	LOG_LOCAL5,
115 	"local6",	LOG_LOCAL6,
116 	"local7",	LOG_LOCAL7,
117 	NULL,		-1,
118 };
119 #endif
120 
121 #ifdef KERNEL
122 #define	LOG_PRINTF	-1	/* pseudo-priority to indicate use of printf */
123 #endif
124 
125 /*
126  * Option flags for openlog.
127  *
128  * LOG_ODELAY no longer does anything.
129  * LOG_NDELAY is the inverse of what it used to be.
130  */
131 #define	LOG_PID		0x01	/* log the pid with each message */
132 #define	LOG_CONS	0x02	/* log on the console if errors in sending */
133 #define	LOG_ODELAY	0x04	/* delay open until first syslog() (default) */
134 #define	LOG_NDELAY	0x08	/* don't delay open */
135 #define	LOG_NOWAIT	0x10	/* don't wait for console forks: DEPRECATED */
136 #define	LOG_PERROR	0x20	/* log to stderr as well */
137