1139825Simp/*- 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 * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 291541Srgrimes * @(#)syslog.h 8.1 (Berkeley) 6/2/93 3050477Speter * $FreeBSD$ 311541Srgrimes */ 321541Srgrimes 332165Spaul#ifndef _SYS_SYSLOG_H_ 342165Spaul#define _SYS_SYSLOG_H_ 352165Spaul 3619137Sjulian#define _PATH_LOG "/var/run/log" 37137233Sglebius#define _PATH_LOG_PRIV "/var/run/logpriv" 3824068Sjdp#define _PATH_OLDLOG "/dev/log" /* backward compatibility */ 391541Srgrimes 401541Srgrimes/* 411541Srgrimes * priorities/facilities are encoded into a single 32-bit quantity, where the 421541Srgrimes * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility 431541Srgrimes * (0-big number). Both the priorities and the facilities map roughly 441541Srgrimes * one-to-one to strings in the syslogd(8) source code. This mapping is 451541Srgrimes * included in this file. 461541Srgrimes * 471541Srgrimes * priorities (these are ordered) 481541Srgrimes */ 491541Srgrimes#define LOG_EMERG 0 /* system is unusable */ 501541Srgrimes#define LOG_ALERT 1 /* action must be taken immediately */ 511541Srgrimes#define LOG_CRIT 2 /* critical conditions */ 521541Srgrimes#define LOG_ERR 3 /* error conditions */ 531541Srgrimes#define LOG_WARNING 4 /* warning conditions */ 541541Srgrimes#define LOG_NOTICE 5 /* normal but significant condition */ 551541Srgrimes#define LOG_INFO 6 /* informational */ 561541Srgrimes#define LOG_DEBUG 7 /* debug-level messages */ 571541Srgrimes 581541Srgrimes#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ 591541Srgrimes /* extract priority */ 601541Srgrimes#define LOG_PRI(p) ((p) & LOG_PRIMASK) 6123252Sjoerg#define LOG_MAKEPRI(fac, pri) ((fac) | (pri)) 621541Srgrimes 631541Srgrimes#ifdef SYSLOG_NAMES 641541Srgrimes#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ 651541Srgrimes /* mark "facility" */ 6630177Sjoerg#define INTERNAL_MARK LOG_MAKEPRI((LOG_NFACILITIES<<3), 0) 671541Srgrimestypedef struct _code { 6876937Sphk const char *c_name; 6976937Sphk int c_val; 701541Srgrimes} CODE; 711541Srgrimes 72249311Sedstatic const CODE prioritynames[] = { 7323127Smpp { "alert", LOG_ALERT, }, 7423127Smpp { "crit", LOG_CRIT, }, 7523127Smpp { "debug", LOG_DEBUG, }, 7623127Smpp { "emerg", LOG_EMERG, }, 7723127Smpp { "err", LOG_ERR, }, 7823127Smpp { "error", LOG_ERR, }, /* DEPRECATED */ 7923127Smpp { "info", LOG_INFO, }, 8023127Smpp { "none", INTERNAL_NOPRI, }, /* INTERNAL */ 8123127Smpp { "notice", LOG_NOTICE, }, 8223127Smpp { "panic", LOG_EMERG, }, /* DEPRECATED */ 8323127Smpp { "warn", LOG_WARNING, }, /* DEPRECATED */ 8423127Smpp { "warning", LOG_WARNING, }, 8523127Smpp { NULL, -1, } 861541Srgrimes}; 871541Srgrimes#endif 881541Srgrimes 891541Srgrimes/* facility codes */ 901541Srgrimes#define LOG_KERN (0<<3) /* kernel messages */ 911541Srgrimes#define LOG_USER (1<<3) /* random user-level messages */ 921541Srgrimes#define LOG_MAIL (2<<3) /* mail system */ 931541Srgrimes#define LOG_DAEMON (3<<3) /* system daemons */ 9450126Sgreen#define LOG_AUTH (4<<3) /* authorization messages */ 951541Srgrimes#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ 961541Srgrimes#define LOG_LPR (6<<3) /* line printer subsystem */ 971541Srgrimes#define LOG_NEWS (7<<3) /* network news subsystem */ 981541Srgrimes#define LOG_UUCP (8<<3) /* UUCP subsystem */ 991541Srgrimes#define LOG_CRON (9<<3) /* clock daemon */ 10050126Sgreen#define LOG_AUTHPRIV (10<<3) /* authorization messages (private) */ 10130183Sjoerg /* Facility #10 clashes in DEC UNIX, where */ 10230183Sjoerg /* it's defined as LOG_MEGASAFE for AdvFS */ 10330183Sjoerg /* event logging. */ 1041541Srgrimes#define LOG_FTP (11<<3) /* ftp daemon */ 10530183Sjoerg#define LOG_NTP (12<<3) /* NTP subsystem */ 10650126Sgreen#define LOG_SECURITY (13<<3) /* security subsystems (firewalling, etc.) */ 10769175Sphk#define LOG_CONSOLE (14<<3) /* /dev/console output */ 1081541Srgrimes 1091541Srgrimes /* other codes through 15 reserved for system use */ 1101541Srgrimes#define LOG_LOCAL0 (16<<3) /* reserved for local use */ 1111541Srgrimes#define LOG_LOCAL1 (17<<3) /* reserved for local use */ 1121541Srgrimes#define LOG_LOCAL2 (18<<3) /* reserved for local use */ 1131541Srgrimes#define LOG_LOCAL3 (19<<3) /* reserved for local use */ 1141541Srgrimes#define LOG_LOCAL4 (20<<3) /* reserved for local use */ 1151541Srgrimes#define LOG_LOCAL5 (21<<3) /* reserved for local use */ 1161541Srgrimes#define LOG_LOCAL6 (22<<3) /* reserved for local use */ 1171541Srgrimes#define LOG_LOCAL7 (23<<3) /* reserved for local use */ 1181541Srgrimes 1191541Srgrimes#define LOG_NFACILITIES 24 /* current number of facilities */ 1201541Srgrimes#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ 1211541Srgrimes /* facility of pri */ 1221541Srgrimes#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) 1231541Srgrimes 1241541Srgrimes#ifdef SYSLOG_NAMES 125249311Sedstatic const CODE facilitynames[] = { 12623127Smpp { "auth", LOG_AUTH, }, 12723127Smpp { "authpriv", LOG_AUTHPRIV, }, 12869175Sphk { "console", LOG_CONSOLE, }, 12923127Smpp { "cron", LOG_CRON, }, 13023127Smpp { "daemon", LOG_DAEMON, }, 13123127Smpp { "ftp", LOG_FTP, }, 13223127Smpp { "kern", LOG_KERN, }, 13323127Smpp { "lpr", LOG_LPR, }, 13423127Smpp { "mail", LOG_MAIL, }, 13523127Smpp { "mark", INTERNAL_MARK, }, /* INTERNAL */ 13623127Smpp { "news", LOG_NEWS, }, 13730183Sjoerg { "ntp", LOG_NTP, }, 13850126Sgreen { "security", LOG_SECURITY, }, 13923127Smpp { "syslog", LOG_SYSLOG, }, 14023127Smpp { "user", LOG_USER, }, 14123127Smpp { "uucp", LOG_UUCP, }, 14223127Smpp { "local0", LOG_LOCAL0, }, 14323127Smpp { "local1", LOG_LOCAL1, }, 14423127Smpp { "local2", LOG_LOCAL2, }, 14523127Smpp { "local3", LOG_LOCAL3, }, 14623127Smpp { "local4", LOG_LOCAL4, }, 14723127Smpp { "local5", LOG_LOCAL5, }, 14823127Smpp { "local6", LOG_LOCAL6, }, 14923127Smpp { "local7", LOG_LOCAL7, }, 15023127Smpp { NULL, -1, } 1511541Srgrimes}; 1521541Srgrimes#endif 1531541Srgrimes 15455205Speter#ifdef _KERNEL 1551541Srgrimes#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ 1561541Srgrimes#endif 1571541Srgrimes 1581541Srgrimes/* 1591541Srgrimes * arguments to setlogmask. 1601541Srgrimes */ 1611541Srgrimes#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ 1621541Srgrimes#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ 1631541Srgrimes 1641541Srgrimes/* 1651541Srgrimes * Option flags for openlog. 1661541Srgrimes * 1671541Srgrimes * LOG_ODELAY no longer does anything. 1681541Srgrimes * LOG_NDELAY is the inverse of what it used to be. 1691541Srgrimes */ 1701541Srgrimes#define LOG_PID 0x01 /* log the pid with each message */ 1711541Srgrimes#define LOG_CONS 0x02 /* log on the console if errors in sending */ 1721541Srgrimes#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 1731541Srgrimes#define LOG_NDELAY 0x08 /* don't delay open */ 1741541Srgrimes#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 1751541Srgrimes#define LOG_PERROR 0x20 /* log to stderr as well */ 1761541Srgrimes 17755205Speter#ifdef _KERNEL 1781541Srgrimes 17955205Speter#else /* not _KERNEL */ 1802112Swollman 1811541Srgrimes/* 1821541Srgrimes * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two 1831541Srgrimes * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one 1841541Srgrimes * of them here we may collide with the utility's includes. It's unreasonable 1851541Srgrimes * for utilities to have to include one of them to include syslog.h, so we get 186102227Smike * __va_list from <sys/_types.h> and use it. 1871541Srgrimes */ 1881541Srgrimes#include <sys/cdefs.h> 189102227Smike#include <sys/_types.h> 1901541Srgrimes 1911541Srgrimes__BEGIN_DECLS 19292719Salfredvoid closelog(void); 19392719Salfredvoid openlog(const char *, int, int); 19492719Salfredint setlogmask(int); 19592719Salfredvoid syslog(int, const char *, ...) __printflike(2, 3); 196189815Sdas#if __BSD_VISIBLE 197102227Smikevoid vsyslog(int, const char *, __va_list) __printflike(2, 0); 198189815Sdas#endif 1991541Srgrimes__END_DECLS 2001541Srgrimes 20155205Speter#endif /* !_KERNEL */ 2022165Spaul 2032165Spaul#endif 204