1 /*@unused@*/ static const char rcsid[] = 2 "@(#)$Id: syslog.h,v 1.6 2002/10/30 06:31:40 carstenklapp Exp $"; 3 4 /* 5 * Copyright (c) 1982, 1986, 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by the University of 19 * California, Berkeley and its contributors. 20 * 4. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)syslog.h 8.1 (Berkeley) 6/2/93 37 * $FreeBSD: src/sys/sys/syslog.h,v 1.19.2.2 2001/05/29 13:15:08 dwmalone Exp $ 38 */ 39 40 #ifndef _SYS_SYSLOG_H_ 41 #define _SYS_SYSLOG_H_ 42 43 #define _PATH_LOG "/var/run/log" 44 #define _PATH_OLDLOG "/dev/log" /* backward compatibility */ 45 46 /* 47 * priorities/facilities are encoded into a single 32-bit quantity, where the 48 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility 49 * (0-big number). Both the priorities and the facilities map roughly 50 * one-to-one to strings in the syslogd(8) source code. This mapping is 51 * included in this file. 52 * 53 * priorities (these are ordered) 54 */ 55 #define LOG_EMERG 0 /* system is unusable */ 56 #define LOG_ALERT 1 /* action must be taken immediately */ 57 #define LOG_CRIT 2 /* critical conditions */ 58 #define LOG_ERR 3 /* error conditions */ 59 #define LOG_WARNING 4 /* warning conditions */ 60 #define LOG_NOTICE 5 /* normal but significant condition */ 61 #define LOG_INFO 6 /* informational */ 62 #define LOG_DEBUG 7 /* debug-level messages */ 63 64 #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ 65 /* extract priority */ 66 #define LOG_PRI(p) ((p) & LOG_PRIMASK) 67 #define LOG_MAKEPRI(fac, pri) ((fac) | (pri)) 68 69 #ifdef SYSLOG_NAMES 70 #define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ 71 /* mark "facility" */ 72 #define INTERNAL_MARK LOG_MAKEPRI((LOG_NFACILITIES<<3), 0) 73 typedef struct _code { 74 const char *c_name; 75 int c_val; 76 } CODE; 77 78 CODE prioritynames[] = { 79 { "alert", LOG_ALERT, }, 80 { "crit", LOG_CRIT, }, 81 { "debug", LOG_DEBUG, }, 82 { "emerg", LOG_EMERG, }, 83 { "err", LOG_ERR, }, 84 { "error", LOG_ERR, }, /* DEPRECATED */ 85 { "info", LOG_INFO, }, 86 { "none", INTERNAL_NOPRI, }, /* INTERNAL */ 87 { "notice", LOG_NOTICE, }, 88 { "panic", LOG_EMERG, }, /* DEPRECATED */ 89 { "warn", LOG_WARNING, }, /* DEPRECATED */ 90 { "warning", LOG_WARNING, }, 91 { NULL, -1, } 92 }; 93 #endif 94 95 /* facility codes */ 96 #define LOG_KERN (0<<3) /* kernel messages */ 97 #define LOG_USER (1<<3) /* random user-level messages */ 98 #define LOG_MAIL (2<<3) /* mail system */ 99 #define LOG_DAEMON (3<<3) /* system daemons */ 100 #define LOG_AUTH (4<<3) /* authorization messages */ 101 #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ 102 #define LOG_LPR (6<<3) /* line printer subsystem */ 103 #define LOG_NEWS (7<<3) /* network news subsystem */ 104 #define LOG_UUCP (8<<3) /* UUCP subsystem */ 105 #define LOG_CRON (9<<3) /* clock daemon */ 106 #define LOG_AUTHPRIV (10<<3) /* authorization messages (private) */ 107 /* Facility #10 clashes in DEC UNIX, where */ 108 /* it's defined as LOG_MEGASAFE for AdvFS */ 109 /* event logging. */ 110 #define LOG_FTP (11<<3) /* ftp daemon */ 111 #define LOG_NTP (12<<3) /* NTP subsystem */ 112 #define LOG_SECURITY (13<<3) /* security subsystems (firewalling, etc.) */ 113 #define LOG_CONSOLE (14<<3) /* /dev/console output */ 114 115 /* other codes through 15 reserved for system use */ 116 #define LOG_LOCAL0 (16<<3) /* reserved for local use */ 117 #define LOG_LOCAL1 (17<<3) /* reserved for local use */ 118 #define LOG_LOCAL2 (18<<3) /* reserved for local use */ 119 #define LOG_LOCAL3 (19<<3) /* reserved for local use */ 120 #define LOG_LOCAL4 (20<<3) /* reserved for local use */ 121 #define LOG_LOCAL5 (21<<3) /* reserved for local use */ 122 #define LOG_LOCAL6 (22<<3) /* reserved for local use */ 123 #define LOG_LOCAL7 (23<<3) /* reserved for local use */ 124 125 #define LOG_NFACILITIES 24 /* current number of facilities */ 126 #define LOG_FACMASK 0x03f8 /* mask to extract facility part */ 127 /* facility of pri */ 128 #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) 129 130 #ifdef SYSLOG_NAMES 131 CODE facilitynames[] = { 132 { "auth", LOG_AUTH, }, 133 { "authpriv", LOG_AUTHPRIV, }, 134 { "console", LOG_CONSOLE, }, 135 { "cron", LOG_CRON, }, 136 { "daemon", LOG_DAEMON, }, 137 { "ftp", LOG_FTP, }, 138 { "kern", LOG_KERN, }, 139 { "lpr", LOG_LPR, }, 140 { "mail", LOG_MAIL, }, 141 { "mark", INTERNAL_MARK, }, /* INTERNAL */ 142 { "news", LOG_NEWS, }, 143 { "ntp", LOG_NTP, }, 144 { "security", LOG_SECURITY, }, 145 { "syslog", LOG_SYSLOG, }, 146 { "user", LOG_USER, }, 147 { "uucp", LOG_UUCP, }, 148 { "local0", LOG_LOCAL0, }, 149 { "local1", LOG_LOCAL1, }, 150 { "local2", LOG_LOCAL2, }, 151 { "local3", LOG_LOCAL3, }, 152 { "local4", LOG_LOCAL4, }, 153 { "local5", LOG_LOCAL5, }, 154 { "local6", LOG_LOCAL6, }, 155 { "local7", LOG_LOCAL7, }, 156 { NULL, -1, } 157 }; 158 #endif 159 160 #ifdef _KERNEL 161 #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ 162 #endif 163 164 /* 165 * arguments to setlogmask. 166 */ 167 #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ 168 #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ 169 170 /* 171 * Option flags for openlog. 172 * 173 * LOG_ODELAY no longer does anything. 174 * LOG_NDELAY is the inverse of what it used to be. 175 */ 176 #define LOG_PID 0x01 /* log the pid with each message */ 177 #define LOG_CONS 0x02 /* log on the console if errors in sending */ 178 #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 179 #define LOG_NDELAY 0x08 /* don't delay open */ 180 #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 181 #define LOG_PERROR 0x20 /* log to stderr as well */ 182 183 #ifdef _KERNEL 184 185 #else /* not _KERNEL */ 186 187 /* 188 * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two 189 * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one 190 * of them here we may collide with the utility's includes. It's unreasonable 191 * for utilities to have to include one of them to include syslog.h, so we get 192 * _BSD_VA_LIST_ from <machine/ansi.h> and use it. 193 */ 194 #include <machine/ansi.h> 195 #include <sys/cdefs.h> 196 197 __BEGIN_DECLS 198 void closelog __P((void)); 199 void openlog __P((const char *, int, int)); 200 int setlogmask __P((int)); 201 void syslog __P((int, const char *, ...)) __printflike(2, 3); 202 void vsyslog __P((int, const char *, _BSD_VA_LIST_)) __printflike(2, 0); 203 __END_DECLS 204 205 #endif /* !_KERNEL */ 206 207 #endif 208