syslog.h revision 2165
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
342165Spaul * $Id: syslog.h,v 1.3 1994/08/18 22:35:46 wollman Exp $
351541Srgrimes */
361541Srgrimes
372165Spaul#ifndef _SYS_SYSLOG_H_
382165Spaul#define _SYS_SYSLOG_H_
392165Spaul
401541Srgrimes#define	_PATH_LOG	"/dev/log"
411541Srgrimes
421541Srgrimes/*
431541Srgrimes * priorities/facilities are encoded into a single 32-bit quantity, where the
441541Srgrimes * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
451541Srgrimes * (0-big number).  Both the priorities and the facilities map roughly
461541Srgrimes * one-to-one to strings in the syslogd(8) source code.  This mapping is
471541Srgrimes * included in this file.
481541Srgrimes *
491541Srgrimes * priorities (these are ordered)
501541Srgrimes */
511541Srgrimes#define	LOG_EMERG	0	/* system is unusable */
521541Srgrimes#define	LOG_ALERT	1	/* action must be taken immediately */
531541Srgrimes#define	LOG_CRIT	2	/* critical conditions */
541541Srgrimes#define	LOG_ERR		3	/* error conditions */
551541Srgrimes#define	LOG_WARNING	4	/* warning conditions */
561541Srgrimes#define	LOG_NOTICE	5	/* normal but significant condition */
571541Srgrimes#define	LOG_INFO	6	/* informational */
581541Srgrimes#define	LOG_DEBUG	7	/* debug-level messages */
591541Srgrimes
601541Srgrimes#define	LOG_PRIMASK	0x07	/* mask to extract priority part (internal) */
611541Srgrimes				/* extract priority */
621541Srgrimes#define	LOG_PRI(p)	((p) & LOG_PRIMASK)
631541Srgrimes#define	LOG_MAKEPRI(fac, pri)	(((fac) << 3) | (pri))
641541Srgrimes
651541Srgrimes#ifdef SYSLOG_NAMES
661541Srgrimes#define	INTERNAL_NOPRI	0x10	/* the "no priority" priority */
671541Srgrimes				/* mark "facility" */
681541Srgrimes#define	INTERNAL_MARK	LOG_MAKEPRI(LOG_NFACILITIES, 0)
691541Srgrimestypedef struct _code {
701541Srgrimes	char	*c_name;
711541Srgrimes	int	c_val;
721541Srgrimes} CODE;
731541Srgrimes
741541SrgrimesCODE prioritynames[] = {
751541Srgrimes	"alert",	LOG_ALERT,
761541Srgrimes	"crit",		LOG_CRIT,
771541Srgrimes	"debug",	LOG_DEBUG,
781541Srgrimes	"emerg",	LOG_EMERG,
791541Srgrimes	"err",		LOG_ERR,
801541Srgrimes	"error",	LOG_ERR,		/* DEPRECATED */
811541Srgrimes	"info",		LOG_INFO,
821541Srgrimes	"none",		INTERNAL_NOPRI,		/* INTERNAL */
831541Srgrimes	"notice",	LOG_NOTICE,
841541Srgrimes	"panic", 	LOG_EMERG,		/* DEPRECATED */
851541Srgrimes	"warn",		LOG_WARNING,		/* DEPRECATED */
861541Srgrimes	"warning",	LOG_WARNING,
871541Srgrimes	NULL,		-1,
881541Srgrimes};
891541Srgrimes#endif
901541Srgrimes
911541Srgrimes/* facility codes */
921541Srgrimes#define	LOG_KERN	(0<<3)	/* kernel messages */
931541Srgrimes#define	LOG_USER	(1<<3)	/* random user-level messages */
941541Srgrimes#define	LOG_MAIL	(2<<3)	/* mail system */
951541Srgrimes#define	LOG_DAEMON	(3<<3)	/* system daemons */
961541Srgrimes#define	LOG_AUTH	(4<<3)	/* security/authorization messages */
971541Srgrimes#define	LOG_SYSLOG	(5<<3)	/* messages generated internally by syslogd */
981541Srgrimes#define	LOG_LPR		(6<<3)	/* line printer subsystem */
991541Srgrimes#define	LOG_NEWS	(7<<3)	/* network news subsystem */
1001541Srgrimes#define	LOG_UUCP	(8<<3)	/* UUCP subsystem */
1011541Srgrimes#define	LOG_CRON	(9<<3)	/* clock daemon */
1021541Srgrimes#define	LOG_AUTHPRIV	(10<<3)	/* security/authorization messages (private) */
1031541Srgrimes#define	LOG_FTP		(11<<3)	/* ftp daemon */
1041541Srgrimes
1051541Srgrimes	/* other codes through 15 reserved for system use */
1061541Srgrimes#define	LOG_LOCAL0	(16<<3)	/* reserved for local use */
1071541Srgrimes#define	LOG_LOCAL1	(17<<3)	/* reserved for local use */
1081541Srgrimes#define	LOG_LOCAL2	(18<<3)	/* reserved for local use */
1091541Srgrimes#define	LOG_LOCAL3	(19<<3)	/* reserved for local use */
1101541Srgrimes#define	LOG_LOCAL4	(20<<3)	/* reserved for local use */
1111541Srgrimes#define	LOG_LOCAL5	(21<<3)	/* reserved for local use */
1121541Srgrimes#define	LOG_LOCAL6	(22<<3)	/* reserved for local use */
1131541Srgrimes#define	LOG_LOCAL7	(23<<3)	/* reserved for local use */
1141541Srgrimes
1151541Srgrimes#define	LOG_NFACILITIES	24	/* current number of facilities */
1161541Srgrimes#define	LOG_FACMASK	0x03f8	/* mask to extract facility part */
1171541Srgrimes				/* facility of pri */
1181541Srgrimes#define	LOG_FAC(p)	(((p) & LOG_FACMASK) >> 3)
1191541Srgrimes
1201541Srgrimes#ifdef SYSLOG_NAMES
1211541SrgrimesCODE facilitynames[] = {
1221541Srgrimes	"auth",		LOG_AUTH,
1231541Srgrimes	"authpriv",	LOG_AUTHPRIV,
1241541Srgrimes	"cron", 	LOG_CRON,
1251541Srgrimes	"daemon",	LOG_DAEMON,
1261541Srgrimes	"ftp",		LOG_FTP,
1271541Srgrimes	"kern",		LOG_KERN,
1281541Srgrimes	"lpr",		LOG_LPR,
1291541Srgrimes	"mail",		LOG_MAIL,
1301541Srgrimes	"mark", 	INTERNAL_MARK,		/* INTERNAL */
1311541Srgrimes	"news",		LOG_NEWS,
1321541Srgrimes	"security",	LOG_AUTH,		/* DEPRECATED */
1331541Srgrimes	"syslog",	LOG_SYSLOG,
1341541Srgrimes	"user",		LOG_USER,
1351541Srgrimes	"uucp",		LOG_UUCP,
1361541Srgrimes	"local0",	LOG_LOCAL0,
1371541Srgrimes	"local1",	LOG_LOCAL1,
1381541Srgrimes	"local2",	LOG_LOCAL2,
1391541Srgrimes	"local3",	LOG_LOCAL3,
1401541Srgrimes	"local4",	LOG_LOCAL4,
1411541Srgrimes	"local5",	LOG_LOCAL5,
1421541Srgrimes	"local6",	LOG_LOCAL6,
1431541Srgrimes	"local7",	LOG_LOCAL7,
1441541Srgrimes	NULL,		-1,
1451541Srgrimes};
1461541Srgrimes#endif
1471541Srgrimes
1481541Srgrimes#ifdef KERNEL
1491541Srgrimes#define	LOG_PRINTF	-1	/* pseudo-priority to indicate use of printf */
1501541Srgrimes#endif
1511541Srgrimes
1521541Srgrimes/*
1531541Srgrimes * arguments to setlogmask.
1541541Srgrimes */
1551541Srgrimes#define	LOG_MASK(pri)	(1 << (pri))		/* mask for one priority */
1561541Srgrimes#define	LOG_UPTO(pri)	((1 << ((pri)+1)) - 1)	/* all priorities through pri */
1571541Srgrimes
1581541Srgrimes/*
1591541Srgrimes * Option flags for openlog.
1601541Srgrimes *
1611541Srgrimes * LOG_ODELAY no longer does anything.
1621541Srgrimes * LOG_NDELAY is the inverse of what it used to be.
1631541Srgrimes */
1641541Srgrimes#define	LOG_PID		0x01	/* log the pid with each message */
1651541Srgrimes#define	LOG_CONS	0x02	/* log on the console if errors in sending */
1661541Srgrimes#define	LOG_ODELAY	0x04	/* delay open until first syslog() (default) */
1671541Srgrimes#define	LOG_NDELAY	0x08	/* don't delay open */
1681541Srgrimes#define	LOG_NOWAIT	0x10	/* don't wait for console forks: DEPRECATED */
1691541Srgrimes#define	LOG_PERROR	0x20	/* log to stderr as well */
1701541Srgrimes
1712112Swollman#ifdef KERNEL
1721541Srgrimes
1732112Swollman#else /* not KERNEL */
1742112Swollman
1751541Srgrimes/*
1761541Srgrimes * Don't use va_list in the vsyslog() prototype.   Va_list is typedef'd in two
1771541Srgrimes * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
1781541Srgrimes * of them here we may collide with the utility's includes.  It's unreasonable
1791541Srgrimes * for utilities to have to include one of them to include syslog.h, so we get
1801541Srgrimes * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
1811541Srgrimes */
1821541Srgrimes#include <machine/ansi.h>
1831541Srgrimes#include <sys/cdefs.h>
1841541Srgrimes
1851541Srgrimes__BEGIN_DECLS
1861541Srgrimesvoid	closelog __P((void));
1871541Srgrimesvoid	openlog __P((const char *, int, int));
1881541Srgrimesint	setlogmask __P((int));
1891541Srgrimesvoid	syslog __P((int, const char *, ...));
1901541Srgrimesvoid	vsyslog __P((int, const char *, _BSD_VA_LIST_));
1911541Srgrimes__END_DECLS
1921541Srgrimes
1931541Srgrimes#endif /* !KERNEL */
1942165Spaul
1952165Spaul#endif
196