syslog.h revision 1541
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1982, 1986, 1988, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
331541Srgrimes *	@(#)syslog.h	8.1 (Berkeley) 6/2/93
341541Srgrimes */
351541Srgrimes
361541Srgrimes#define	_PATH_LOG	"/dev/log"
371541Srgrimes
381541Srgrimes/*
391541Srgrimes * priorities/facilities are encoded into a single 32-bit quantity, where the
401541Srgrimes * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
411541Srgrimes * (0-big number).  Both the priorities and the facilities map roughly
421541Srgrimes * one-to-one to strings in the syslogd(8) source code.  This mapping is
431541Srgrimes * included in this file.
441541Srgrimes *
451541Srgrimes * priorities (these are ordered)
461541Srgrimes */
471541Srgrimes#define	LOG_EMERG	0	/* system is unusable */
481541Srgrimes#define	LOG_ALERT	1	/* action must be taken immediately */
491541Srgrimes#define	LOG_CRIT	2	/* critical conditions */
501541Srgrimes#define	LOG_ERR		3	/* error conditions */
511541Srgrimes#define	LOG_WARNING	4	/* warning conditions */
521541Srgrimes#define	LOG_NOTICE	5	/* normal but significant condition */
531541Srgrimes#define	LOG_INFO	6	/* informational */
541541Srgrimes#define	LOG_DEBUG	7	/* debug-level messages */
551541Srgrimes
561541Srgrimes#define	LOG_PRIMASK	0x07	/* mask to extract priority part (internal) */
571541Srgrimes				/* extract priority */
581541Srgrimes#define	LOG_PRI(p)	((p) & LOG_PRIMASK)
591541Srgrimes#define	LOG_MAKEPRI(fac, pri)	(((fac) << 3) | (pri))
601541Srgrimes
611541Srgrimes#ifdef SYSLOG_NAMES
621541Srgrimes#define	INTERNAL_NOPRI	0x10	/* the "no priority" priority */
631541Srgrimes				/* mark "facility" */
641541Srgrimes#define	INTERNAL_MARK	LOG_MAKEPRI(LOG_NFACILITIES, 0)
651541Srgrimestypedef struct _code {
661541Srgrimes	char	*c_name;
671541Srgrimes	int	c_val;
681541Srgrimes} CODE;
691541Srgrimes
701541SrgrimesCODE prioritynames[] = {
711541Srgrimes	"alert",	LOG_ALERT,
721541Srgrimes	"crit",		LOG_CRIT,
731541Srgrimes	"debug",	LOG_DEBUG,
741541Srgrimes	"emerg",	LOG_EMERG,
751541Srgrimes	"err",		LOG_ERR,
761541Srgrimes	"error",	LOG_ERR,		/* DEPRECATED */
771541Srgrimes	"info",		LOG_INFO,
781541Srgrimes	"none",		INTERNAL_NOPRI,		/* INTERNAL */
791541Srgrimes	"notice",	LOG_NOTICE,
801541Srgrimes	"panic", 	LOG_EMERG,		/* DEPRECATED */
811541Srgrimes	"warn",		LOG_WARNING,		/* DEPRECATED */
821541Srgrimes	"warning",	LOG_WARNING,
831541Srgrimes	NULL,		-1,
841541Srgrimes};
851541Srgrimes#endif
861541Srgrimes
871541Srgrimes/* facility codes */
881541Srgrimes#define	LOG_KERN	(0<<3)	/* kernel messages */
891541Srgrimes#define	LOG_USER	(1<<3)	/* random user-level messages */
901541Srgrimes#define	LOG_MAIL	(2<<3)	/* mail system */
911541Srgrimes#define	LOG_DAEMON	(3<<3)	/* system daemons */
921541Srgrimes#define	LOG_AUTH	(4<<3)	/* security/authorization messages */
931541Srgrimes#define	LOG_SYSLOG	(5<<3)	/* messages generated internally by syslogd */
941541Srgrimes#define	LOG_LPR		(6<<3)	/* line printer subsystem */
951541Srgrimes#define	LOG_NEWS	(7<<3)	/* network news subsystem */
961541Srgrimes#define	LOG_UUCP	(8<<3)	/* UUCP subsystem */
971541Srgrimes#define	LOG_CRON	(9<<3)	/* clock daemon */
981541Srgrimes#define	LOG_AUTHPRIV	(10<<3)	/* security/authorization messages (private) */
991541Srgrimes#define	LOG_FTP		(11<<3)	/* ftp daemon */
1001541Srgrimes
1011541Srgrimes	/* other codes through 15 reserved for system use */
1021541Srgrimes#define	LOG_LOCAL0	(16<<3)	/* reserved for local use */
1031541Srgrimes#define	LOG_LOCAL1	(17<<3)	/* reserved for local use */
1041541Srgrimes#define	LOG_LOCAL2	(18<<3)	/* reserved for local use */
1051541Srgrimes#define	LOG_LOCAL3	(19<<3)	/* reserved for local use */
1061541Srgrimes#define	LOG_LOCAL4	(20<<3)	/* reserved for local use */
1071541Srgrimes#define	LOG_LOCAL5	(21<<3)	/* reserved for local use */
1081541Srgrimes#define	LOG_LOCAL6	(22<<3)	/* reserved for local use */
1091541Srgrimes#define	LOG_LOCAL7	(23<<3)	/* reserved for local use */
1101541Srgrimes
1111541Srgrimes#define	LOG_NFACILITIES	24	/* current number of facilities */
1121541Srgrimes#define	LOG_FACMASK	0x03f8	/* mask to extract facility part */
1131541Srgrimes				/* facility of pri */
1141541Srgrimes#define	LOG_FAC(p)	(((p) & LOG_FACMASK) >> 3)
1151541Srgrimes
1161541Srgrimes#ifdef SYSLOG_NAMES
1171541SrgrimesCODE facilitynames[] = {
1181541Srgrimes	"auth",		LOG_AUTH,
1191541Srgrimes	"authpriv",	LOG_AUTHPRIV,
1201541Srgrimes	"cron", 	LOG_CRON,
1211541Srgrimes	"daemon",	LOG_DAEMON,
1221541Srgrimes	"ftp",		LOG_FTP,
1231541Srgrimes	"kern",		LOG_KERN,
1241541Srgrimes	"lpr",		LOG_LPR,
1251541Srgrimes	"mail",		LOG_MAIL,
1261541Srgrimes	"mark", 	INTERNAL_MARK,		/* INTERNAL */
1271541Srgrimes	"news",		LOG_NEWS,
1281541Srgrimes	"security",	LOG_AUTH,		/* DEPRECATED */
1291541Srgrimes	"syslog",	LOG_SYSLOG,
1301541Srgrimes	"user",		LOG_USER,
1311541Srgrimes	"uucp",		LOG_UUCP,
1321541Srgrimes	"local0",	LOG_LOCAL0,
1331541Srgrimes	"local1",	LOG_LOCAL1,
1341541Srgrimes	"local2",	LOG_LOCAL2,
1351541Srgrimes	"local3",	LOG_LOCAL3,
1361541Srgrimes	"local4",	LOG_LOCAL4,
1371541Srgrimes	"local5",	LOG_LOCAL5,
1381541Srgrimes	"local6",	LOG_LOCAL6,
1391541Srgrimes	"local7",	LOG_LOCAL7,
1401541Srgrimes	NULL,		-1,
1411541Srgrimes};
1421541Srgrimes#endif
1431541Srgrimes
1441541Srgrimes#ifdef KERNEL
1451541Srgrimes#define	LOG_PRINTF	-1	/* pseudo-priority to indicate use of printf */
1461541Srgrimes#endif
1471541Srgrimes
1481541Srgrimes/*
1491541Srgrimes * arguments to setlogmask.
1501541Srgrimes */
1511541Srgrimes#define	LOG_MASK(pri)	(1 << (pri))		/* mask for one priority */
1521541Srgrimes#define	LOG_UPTO(pri)	((1 << ((pri)+1)) - 1)	/* all priorities through pri */
1531541Srgrimes
1541541Srgrimes/*
1551541Srgrimes * Option flags for openlog.
1561541Srgrimes *
1571541Srgrimes * LOG_ODELAY no longer does anything.
1581541Srgrimes * LOG_NDELAY is the inverse of what it used to be.
1591541Srgrimes */
1601541Srgrimes#define	LOG_PID		0x01	/* log the pid with each message */
1611541Srgrimes#define	LOG_CONS	0x02	/* log on the console if errors in sending */
1621541Srgrimes#define	LOG_ODELAY	0x04	/* delay open until first syslog() (default) */
1631541Srgrimes#define	LOG_NDELAY	0x08	/* don't delay open */
1641541Srgrimes#define	LOG_NOWAIT	0x10	/* don't wait for console forks: DEPRECATED */
1651541Srgrimes#define	LOG_PERROR	0x20	/* log to stderr as well */
1661541Srgrimes
1671541Srgrimes#ifndef KERNEL
1681541Srgrimes
1691541Srgrimes/*
1701541Srgrimes * Don't use va_list in the vsyslog() prototype.   Va_list is typedef'd in two
1711541Srgrimes * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
1721541Srgrimes * of them here we may collide with the utility's includes.  It's unreasonable
1731541Srgrimes * for utilities to have to include one of them to include syslog.h, so we get
1741541Srgrimes * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
1751541Srgrimes */
1761541Srgrimes#include <machine/ansi.h>
1771541Srgrimes#include <sys/cdefs.h>
1781541Srgrimes
1791541Srgrimes__BEGIN_DECLS
1801541Srgrimesvoid	closelog __P((void));
1811541Srgrimesvoid	openlog __P((const char *, int, int));
1821541Srgrimesint	setlogmask __P((int));
1831541Srgrimesvoid	syslog __P((int, const char *, ...));
1841541Srgrimesvoid	vsyslog __P((int, const char *, _BSD_VA_LIST_));
1851541Srgrimes__END_DECLS
1861541Srgrimes
1871541Srgrimes#endif /* !KERNEL */
188