00001 #ifndef _SYS_SYSLOG_H_ 00002 #define _SYS_SYSLOG_H_ 00003 /* 00004 * Copyright (C) 2001-2004 by egnite Software GmbH. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 3. Neither the name of the copyright holders nor the names of 00016 * contributors may be used to endorse or promote products derived 00017 * from this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS 00020 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00022 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE 00023 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00024 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00025 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00026 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00027 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00028 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00029 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00030 * SUCH DAMAGE. 00031 * 00032 * For additional information see http://www.ethernut.de/ 00033 * 00034 * - 00035 * Portions Copyright (c) 1982, 1986, 1988, 1993 00036 * The Regents of the University of California. All rights reserved. 00037 * 00038 * Redistribution and use in source and binary forms, with or without 00039 * modification, are permitted provided that the following conditions 00040 * are met: 00041 * 1. Redistributions of source code must retain the above copyright 00042 * notice, this list of conditions and the following disclaimer. 00043 * 2. Redistributions in binary form must reproduce the above copyright 00044 * notice, this list of conditions and the following disclaimer in the 00045 * documentation and/or other materials provided with the distribution. 00046 * 3. Neither the name of the University nor the names of its contributors 00047 * may be used to endorse or promote products derived from this software 00048 * without specific prior written permission. 00049 * 00050 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00051 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00052 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00053 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00054 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00055 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00056 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00057 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00058 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00059 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00060 * SUCH DAMAGE. 00061 * 00062 */ 00063 00064 /* 00065 * $Log$ 00066 * Revision 1.6 2008/08/11 07:00:28 haraldkipp 00067 * BSD types replaced by stdint types (feature request #1282721). 00068 * 00069 * Revision 1.5 2004/11/24 16:41:18 haraldkipp 00070 * Wrong prototypes for _P routines fixed 00071 * 00072 * Revision 1.4 2004/10/03 18:41:43 haraldkipp 00073 * RAM saving calls added 00074 * 00075 * Revision 1.3 2004/09/19 11:18:44 haraldkipp 00076 * Syslog client added 00077 * 00078 */ 00079 00080 /* 00081 * priorities/facilities are encoded into a single 32-bit quantity, where the 00082 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility 00083 * (0-big number). Both the priorities and the facilities map roughly 00084 * one-to-one to strings in the syslogd(8) source code. This mapping is 00085 * included in this file. 00086 * 00087 * priorities (these are ordered) 00088 */ 00089 00090 #include <sys/types.h> 00091 #include <stdint.h> 00092 #include <stdarg.h> 00093 00094 #define LOG_EMERG 0 /* system is unusable */ 00095 #define LOG_ALERT 1 /* action must be taken immediately */ 00096 #define LOG_CRIT 2 /* critical conditions */ 00097 #define LOG_ERR 3 /* error conditions */ 00098 #define LOG_WARNING 4 /* warning conditions */ 00099 #define LOG_NOTICE 5 /* normal but significant condition */ 00100 #define LOG_INFO 6 /* informational */ 00101 #define LOG_DEBUG 7 /* debug-level messages */ 00102 00103 #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ 00104 /* extract priority */ 00105 #define LOG_PRI(p) ((p) & LOG_PRIMASK) 00106 #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) 00107 00108 /* facility codes */ 00109 #define LOG_KERN (0<<3) /* kernel messages */ 00110 #define LOG_USER (1<<3) /* random user-level messages */ 00111 #define LOG_MAIL (2<<3) /* mail system */ 00112 #define LOG_DAEMON (3<<3) /* system daemons */ 00113 #define LOG_AUTH (4<<3) /* security/authorization messages */ 00114 #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ 00115 #define LOG_LPR (6<<3) /* line printer subsystem */ 00116 #define LOG_NEWS (7<<3) /* network news subsystem */ 00117 #define LOG_UUCP (8<<3) /* UUCP subsystem */ 00118 #define LOG_CRON (9<<3) /* clock daemon */ 00119 #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ 00120 #define LOG_FTP (11<<3) /* ftp daemon */ 00121 00122 /* other codes through 15 reserved for system use */ 00123 #define LOG_LOCAL0 (16<<3) /* reserved for local use */ 00124 #define LOG_LOCAL1 (17<<3) /* reserved for local use */ 00125 #define LOG_LOCAL2 (18<<3) /* reserved for local use */ 00126 #define LOG_LOCAL3 (19<<3) /* reserved for local use */ 00127 #define LOG_LOCAL4 (20<<3) /* reserved for local use */ 00128 #define LOG_LOCAL5 (21<<3) /* reserved for local use */ 00129 #define LOG_LOCAL6 (22<<3) /* reserved for local use */ 00130 #define LOG_LOCAL7 (23<<3) /* reserved for local use */ 00131 00132 #define LOG_NFACILITIES 24 /* current number of facilities */ 00133 #define LOG_FACMASK 0x03f8 /* mask to extract facility part */ 00134 /* facility of pri */ 00135 #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) 00136 00137 #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ 00138 00139 /* 00140 * arguments to setlogmask. 00141 */ 00142 #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ 00143 #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ 00144 00145 /* 00146 * Option flags for openlog. 00147 * 00148 * LOG_ODELAY no longer does anything. 00149 * LOG_NDELAY is the inverse of what it used to be. 00150 */ 00151 #define LOG_PID 0x01 /* log the pid with each message */ 00152 #define LOG_CONS 0x02 /* log on the console if errors in sending */ 00153 #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 00154 #define LOG_NDELAY 0x08 /* don't delay open */ 00155 #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 00156 #define LOG_PERROR 0x20 /* log to stderr as well */ 00157 00158 #ifdef SYSLOG_INTERNAL 00159 00160 #ifndef SYSLOG_MAXBUF 00161 00164 #define SYSLOG_MAXBUF 256 00165 #endif 00166 00167 extern char *syslog_buf; 00168 00169 #endif /* SYSLOG_INTERNAL */ 00170 00171 __BEGIN_DECLS /* */ 00172 extern void closelog(void); 00173 extern void openlog(CONST char *, int, int); 00174 extern int setlogmask(int); 00175 extern uint32_t setlogserver(uint32_t ip, uint16_t port); 00176 extern void syslog(int, CONST char *, ...); 00177 extern void vsyslog(int, CONST char *, va_list); 00178 #ifdef __HARVARD_ARCH__ 00179 #ifdef SYSLOG_INTERNAL 00180 extern size_t syslog_header(int pri); 00181 extern void syslog_flush(size_t len); 00182 #endif 00183 extern void syslog_P(int pri, PGM_P fmt, ...); 00184 extern void vsyslog_P(int pri, PGM_P fmt, va_list ap); 00185 #else 00186 #define syslog_P syslog 00187 #define vsyslog_P vsyslog 00188 #endif 00189 __END_DECLS /* */ 00190 #endif