xref: /original-bsd/sys/sys/syslog.h (revision 83adbb3c)
1 /*
2  * Copyright (c) 1982, 1986, 1988, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)syslog.h	8.1 (Berkeley) 06/02/93
8  */
9 
10 #define	_PATH_LOG	"/dev/log"
11 
12 /*
13  * priorities/facilities are encoded into a single 32-bit quantity, where the
14  * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
15  * (0-big number).  Both the priorities and the facilities map roughly
16  * one-to-one to strings in the syslogd(8) source code.  This mapping is
17  * included in this file.
18  *
19  * priorities (these are ordered)
20  */
21 #define	LOG_EMERG	0	/* system is unusable */
22 #define	LOG_ALERT	1	/* action must be taken immediately */
23 #define	LOG_CRIT	2	/* critical conditions */
24 #define	LOG_ERR		3	/* error conditions */
25 #define	LOG_WARNING	4	/* warning conditions */
26 #define	LOG_NOTICE	5	/* normal but significant condition */
27 #define	LOG_INFO	6	/* informational */
28 #define	LOG_DEBUG	7	/* debug-level messages */
29 
30 #define	LOG_PRIMASK	0x07	/* mask to extract priority part (internal) */
31 				/* extract priority */
32 #define	LOG_PRI(p)	((p) & LOG_PRIMASK)
33 #define	LOG_MAKEPRI(fac, pri)	(((fac) << 3) | (pri))
34 
35 #ifdef SYSLOG_NAMES
36 #define	INTERNAL_NOPRI	0x10	/* the "no priority" priority */
37 				/* mark "facility" */
38 #define	INTERNAL_MARK	LOG_MAKEPRI(LOG_NFACILITIES, 0)
39 typedef struct _code {
40 	char	*c_name;
41 	int	c_val;
42 } CODE;
43 
44 CODE prioritynames[] = {
45 	"alert",	LOG_ALERT,
46 	"crit",		LOG_CRIT,
47 	"debug",	LOG_DEBUG,
48 	"emerg",	LOG_EMERG,
49 	"err",		LOG_ERR,
50 	"error",	LOG_ERR,		/* DEPRECATED */
51 	"info",		LOG_INFO,
52 	"none",		INTERNAL_NOPRI,		/* INTERNAL */
53 	"notice",	LOG_NOTICE,
54 	"panic", 	LOG_EMERG,		/* DEPRECATED */
55 	"warn",		LOG_WARNING,		/* DEPRECATED */
56 	"warning",	LOG_WARNING,
57 	NULL,		-1,
58 };
59 #endif
60 
61 /* facility codes */
62 #define	LOG_KERN	(0<<3)	/* kernel messages */
63 #define	LOG_USER	(1<<3)	/* random user-level messages */
64 #define	LOG_MAIL	(2<<3)	/* mail system */
65 #define	LOG_DAEMON	(3<<3)	/* system daemons */
66 #define	LOG_AUTH	(4<<3)	/* security/authorization messages */
67 #define	LOG_SYSLOG	(5<<3)	/* messages generated internally by syslogd */
68 #define	LOG_LPR		(6<<3)	/* line printer subsystem */
69 #define	LOG_NEWS	(7<<3)	/* network news subsystem */
70 #define	LOG_UUCP	(8<<3)	/* UUCP subsystem */
71 #define	LOG_CRON	(9<<3)	/* clock daemon */
72 #define	LOG_AUTHPRIV	(10<<3)	/* security/authorization messages (private) */
73 #define	LOG_FTP		(11<<3)	/* ftp daemon */
74 
75 	/* other codes through 15 reserved for system use */
76 #define	LOG_LOCAL0	(16<<3)	/* reserved for local use */
77 #define	LOG_LOCAL1	(17<<3)	/* reserved for local use */
78 #define	LOG_LOCAL2	(18<<3)	/* reserved for local use */
79 #define	LOG_LOCAL3	(19<<3)	/* reserved for local use */
80 #define	LOG_LOCAL4	(20<<3)	/* reserved for local use */
81 #define	LOG_LOCAL5	(21<<3)	/* reserved for local use */
82 #define	LOG_LOCAL6	(22<<3)	/* reserved for local use */
83 #define	LOG_LOCAL7	(23<<3)	/* reserved for local use */
84 
85 #define	LOG_NFACILITIES	24	/* current number of facilities */
86 #define	LOG_FACMASK	0x03f8	/* mask to extract facility part */
87 				/* facility of pri */
88 #define	LOG_FAC(p)	(((p) & LOG_FACMASK) >> 3)
89 
90 #ifdef SYSLOG_NAMES
91 CODE facilitynames[] = {
92 	"auth",		LOG_AUTH,
93 	"authpriv",	LOG_AUTHPRIV,
94 	"cron", 	LOG_CRON,
95 	"daemon",	LOG_DAEMON,
96 	"ftp",		LOG_FTP,
97 	"kern",		LOG_KERN,
98 	"lpr",		LOG_LPR,
99 	"mail",		LOG_MAIL,
100 	"mark", 	INTERNAL_MARK,		/* INTERNAL */
101 	"news",		LOG_NEWS,
102 	"security",	LOG_AUTH,		/* DEPRECATED */
103 	"syslog",	LOG_SYSLOG,
104 	"user",		LOG_USER,
105 	"uucp",		LOG_UUCP,
106 	"local0",	LOG_LOCAL0,
107 	"local1",	LOG_LOCAL1,
108 	"local2",	LOG_LOCAL2,
109 	"local3",	LOG_LOCAL3,
110 	"local4",	LOG_LOCAL4,
111 	"local5",	LOG_LOCAL5,
112 	"local6",	LOG_LOCAL6,
113 	"local7",	LOG_LOCAL7,
114 	NULL,		-1,
115 };
116 #endif
117 
118 #ifdef KERNEL
119 #define	LOG_PRINTF	-1	/* pseudo-priority to indicate use of printf */
120 #endif
121 
122 /*
123  * Option flags for openlog.
124  *
125  * LOG_ODELAY no longer does anything.
126  * LOG_NDELAY is the inverse of what it used to be.
127  */
128 #define	LOG_PID		0x01	/* log the pid with each message */
129 #define	LOG_CONS	0x02	/* log on the console if errors in sending */
130 #define	LOG_ODELAY	0x04	/* delay open until first syslog() (default) */
131 #define	LOG_NDELAY	0x08	/* don't delay open */
132 #define	LOG_NOWAIT	0x10	/* don't wait for console forks: DEPRECATED */
133 #define	LOG_PERROR	0x20	/* log to stderr as well */
134 
135 #ifndef KERNEL
136 
137 /*
138  * Don't use va_list in the vsyslog() prototype.   Va_list is typedef'd in two
139  * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
140  * of them here we may collide with the utility's includes.  It's unreasonable
141  * for utilities to have to include one of them to include syslog.h, so we get
142  * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
143  */
144 #include <machine/ansi.h>
145 #include <sys/cdefs.h>
146 
147 __BEGIN_DECLS
148 void	closelog __P((void));
149 void	openlog __P((const char *, int, int));
150 int	setlogmask __P((int));
151 void	syslog __P((int, const char *, ...));
152 void	vsyslog __P((int, const char *, _BSD_VA_LIST_));
153 __END_DECLS
154 
155 #endif /* !KERNEL */
156