1 /* 2 * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)syslog.h 7.21 (Berkeley) 02/21/92 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 74 /* other codes through 15 reserved for system use */ 75 #define LOG_LOCAL0 (16<<3) /* reserved for local use */ 76 #define LOG_LOCAL1 (17<<3) /* reserved for local use */ 77 #define LOG_LOCAL2 (18<<3) /* reserved for local use */ 78 #define LOG_LOCAL3 (19<<3) /* reserved for local use */ 79 #define LOG_LOCAL4 (20<<3) /* reserved for local use */ 80 #define LOG_LOCAL5 (21<<3) /* reserved for local use */ 81 #define LOG_LOCAL6 (22<<3) /* reserved for local use */ 82 #define LOG_LOCAL7 (23<<3) /* reserved for local use */ 83 84 #define LOG_NFACILITIES 24 /* current number of facilities */ 85 #define LOG_FACMASK 0x03f8 /* mask to extract facility part */ 86 /* facility of pri */ 87 #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) 88 89 #ifdef SYSLOG_NAMES 90 CODE facilitynames[] = { 91 "auth", LOG_AUTH, 92 "authpriv", LOG_AUTHPRIV, 93 "cron", LOG_CRON, 94 "daemon", LOG_DAEMON, 95 "kern", LOG_KERN, 96 "lpr", LOG_LPR, 97 "mail", LOG_MAIL, 98 "mark", INTERNAL_MARK, /* INTERNAL */ 99 "news", LOG_NEWS, 100 "security", LOG_AUTH, /* DEPRECATED */ 101 "syslog", LOG_SYSLOG, 102 "user", LOG_USER, 103 "uucp", LOG_UUCP, 104 "local0", LOG_LOCAL0, 105 "local1", LOG_LOCAL1, 106 "local2", LOG_LOCAL2, 107 "local3", LOG_LOCAL3, 108 "local4", LOG_LOCAL4, 109 "local5", LOG_LOCAL5, 110 "local6", LOG_LOCAL6, 111 "local7", LOG_LOCAL7, 112 NULL, -1, 113 }; 114 #endif 115 116 #ifdef KERNEL 117 #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ 118 #endif 119 120 /* 121 * Option flags for openlog. 122 * 123 * LOG_ODELAY no longer does anything. 124 * LOG_NDELAY is the inverse of what it used to be. 125 */ 126 #define LOG_PID 0x01 /* log the pid with each message */ 127 #define LOG_CONS 0x02 /* log on the console if errors in sending */ 128 #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 129 #define LOG_NDELAY 0x08 /* don't delay open */ 130 #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 131 #define LOG_PERROR 0x20 /* log to stderr as well */ 132 133 #ifndef KERNEL 134 135 /* 136 * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two 137 * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one 138 * of them here we may collide with the utility's includes. It's unreasonable 139 * for utilities to have to include one of them to include syslog.h, so we get 140 * _VA_LIST_ from <machine/ansi.h> and use it. 141 */ 142 #include <machine/ansi.h> 143 #include <sys/cdefs.h> 144 145 __BEGIN_DECLS 146 void closelog __P((void)); 147 void openlog __P((const char *, int, int)); 148 int setlogmask __P((int)); 149 void syslog __P((int, const char *, ...)); 150 void vsyslog __P((int, const char *, _VA_LIST_)); 151 __END_DECLS 152 153 #endif /* !KERNEL */ 154