Back to index

glibc  2.9
syslog.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1982, 1986, 1988, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  *     @(#)syslog.h  8.1 (Berkeley) 6/2/93
00030  */
00031 
00032 #ifndef _SYS_SYSLOG_H
00033 #define _SYS_SYSLOG_H 1
00034 
00035 #include <features.h>
00036 #define __need___va_list
00037 #include <stdarg.h>
00038 
00039 /* This file defines _PATH_LOG.  */
00040 #include <bits/syslog-path.h>
00041 
00042 /*
00043  * priorities/facilities are encoded into a single 32-bit quantity, where the
00044  * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
00045  * (0-big number).  Both the priorities and the facilities map roughly
00046  * one-to-one to strings in the syslogd(8) source code.  This mapping is
00047  * included in this file.
00048  *
00049  * priorities (these are ordered)
00050  */
00051 #define       LOG_EMERG     0      /* system is unusable */
00052 #define       LOG_ALERT     1      /* action must be taken immediately */
00053 #define       LOG_CRIT      2      /* critical conditions */
00054 #define       LOG_ERR              3      /* error conditions */
00055 #define       LOG_WARNING   4      /* warning conditions */
00056 #define       LOG_NOTICE    5      /* normal but significant condition */
00057 #define       LOG_INFO      6      /* informational */
00058 #define       LOG_DEBUG     7      /* debug-level messages */
00059 
00060 #define       LOG_PRIMASK   0x07   /* mask to extract priority part (internal) */
00061                             /* extract priority */
00062 #define       LOG_PRI(p)    ((p) & LOG_PRIMASK)
00063 #define       LOG_MAKEPRI(fac, pri)       (((fac) << 3) | (pri))
00064 
00065 #ifdef SYSLOG_NAMES
00066 #define       INTERNAL_NOPRI       0x10   /* the "no priority" priority */
00067                             /* mark "facility" */
00068 #define       INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0)
00069 typedef struct _code {
00070        char   *c_name;
00071        int    c_val;
00072 } CODE;
00073 
00074 CODE prioritynames[] =
00075   {
00076     { "alert", LOG_ALERT },
00077     { "crit", LOG_CRIT },
00078     { "debug", LOG_DEBUG },
00079     { "emerg", LOG_EMERG },
00080     { "err", LOG_ERR },
00081     { "error", LOG_ERR },          /* DEPRECATED */
00082     { "info", LOG_INFO },
00083     { "none", INTERNAL_NOPRI },           /* INTERNAL */
00084     { "notice", LOG_NOTICE },
00085     { "panic", LOG_EMERG },        /* DEPRECATED */
00086     { "warn", LOG_WARNING },              /* DEPRECATED */
00087     { "warning", LOG_WARNING },
00088     { NULL, -1 }
00089   };
00090 #endif
00091 
00092 /* facility codes */
00093 #define       LOG_KERN      (0<<3) /* kernel messages */
00094 #define       LOG_USER      (1<<3) /* random user-level messages */
00095 #define       LOG_MAIL      (2<<3) /* mail system */
00096 #define       LOG_DAEMON    (3<<3) /* system daemons */
00097 #define       LOG_AUTH      (4<<3) /* security/authorization messages */
00098 #define       LOG_SYSLOG    (5<<3) /* messages generated internally by syslogd */
00099 #define       LOG_LPR              (6<<3) /* line printer subsystem */
00100 #define       LOG_NEWS      (7<<3) /* network news subsystem */
00101 #define       LOG_UUCP      (8<<3) /* UUCP subsystem */
00102 #define       LOG_CRON      (9<<3) /* clock daemon */
00103 #define       LOG_AUTHPRIV  (10<<3)       /* security/authorization messages (private) */
00104 #define       LOG_FTP              (11<<3)       /* ftp daemon */
00105 
00106        /* other codes through 15 reserved for system use */
00107 #define       LOG_LOCAL0    (16<<3)       /* reserved for local use */
00108 #define       LOG_LOCAL1    (17<<3)       /* reserved for local use */
00109 #define       LOG_LOCAL2    (18<<3)       /* reserved for local use */
00110 #define       LOG_LOCAL3    (19<<3)       /* reserved for local use */
00111 #define       LOG_LOCAL4    (20<<3)       /* reserved for local use */
00112 #define       LOG_LOCAL5    (21<<3)       /* reserved for local use */
00113 #define       LOG_LOCAL6    (22<<3)       /* reserved for local use */
00114 #define       LOG_LOCAL7    (23<<3)       /* reserved for local use */
00115 
00116 #define       LOG_NFACILITIES      24     /* current number of facilities */
00117 #define       LOG_FACMASK   0x03f8 /* mask to extract facility part */
00118                             /* facility of pri */
00119 #define       LOG_FAC(p)    (((p) & LOG_FACMASK) >> 3)
00120 
00121 #ifdef SYSLOG_NAMES
00122 CODE facilitynames[] =
00123   {
00124     { "auth", LOG_AUTH },
00125     { "authpriv", LOG_AUTHPRIV },
00126     { "cron", LOG_CRON },
00127     { "daemon", LOG_DAEMON },
00128     { "ftp", LOG_FTP },
00129     { "kern", LOG_KERN },
00130     { "lpr", LOG_LPR },
00131     { "mail", LOG_MAIL },
00132     { "mark", INTERNAL_MARK },            /* INTERNAL */
00133     { "news", LOG_NEWS },
00134     { "security", LOG_AUTH },             /* DEPRECATED */
00135     { "syslog", LOG_SYSLOG },
00136     { "user", LOG_USER },
00137     { "uucp", LOG_UUCP },
00138     { "local0", LOG_LOCAL0 },
00139     { "local1", LOG_LOCAL1 },
00140     { "local2", LOG_LOCAL2 },
00141     { "local3", LOG_LOCAL3 },
00142     { "local4", LOG_LOCAL4 },
00143     { "local5", LOG_LOCAL5 },
00144     { "local6", LOG_LOCAL6 },
00145     { "local7", LOG_LOCAL7 },
00146     { NULL, -1 }
00147   };
00148 #endif
00149 
00150 /*
00151  * arguments to setlogmask.
00152  */
00153 #define       LOG_MASK(pri) (1 << (pri))         /* mask for one priority */
00154 #define       LOG_UPTO(pri) ((1 << ((pri)+1)) - 1)      /* all priorities through pri */
00155 
00156 /*
00157  * Option flags for openlog.
00158  *
00159  * LOG_ODELAY no longer does anything.
00160  * LOG_NDELAY is the inverse of what it used to be.
00161  */
00162 #define       LOG_PID              0x01   /* log the pid with each message */
00163 #define       LOG_CONS      0x02   /* log on the console if errors in sending */
00164 #define       LOG_ODELAY    0x04   /* delay open until first syslog() (default) */
00165 #define       LOG_NDELAY    0x08   /* don't delay open */
00166 #define       LOG_NOWAIT    0x10   /* don't wait for console forks: DEPRECATED */
00167 #define       LOG_PERROR    0x20   /* log to stderr as well */
00168 
00169 __BEGIN_DECLS
00170 
00171 /* Close descriptor used to write to system logger.
00172 
00173    This function is a possible cancellation point and therefore not
00174    marked with __THROW.  */
00175 extern void closelog (void);
00176 
00177 /* Open connection to system logger.
00178 
00179    This function is a possible cancellation point and therefore not
00180    marked with __THROW.  */
00181 extern void openlog (__const char *__ident, int __option, int __facility);
00182 
00183 /* Set the log mask level.  */
00184 extern int setlogmask (int __mask) __THROW;
00185 
00186 /* Generate a log message using FMT string and option arguments.
00187 
00188    This function is a possible cancellation point and therefore not
00189    marked with __THROW.  */
00190 extern void syslog (int __pri, __const char *__fmt, ...)
00191      __attribute__ ((__format__ (__printf__, 2, 3)));
00192 
00193 #ifdef __USE_BSD
00194 /* Generate a log message using FMT and using arguments pointed to by AP.
00195 
00196    This function is not part of POSIX and therefore no official
00197    cancellation point.  But due to similarity with an POSIX interface
00198    or due to the implementation it is a cancellation point and
00199    therefore not marked with __THROW.  */
00200 extern void vsyslog (int __pri, __const char *__fmt, __gnuc_va_list __ap)
00201      __attribute__ ((__format__ (__printf__, 2, 0)));
00202 #endif
00203 
00204 
00205 /* Define some macros helping to catch buffer overflows.  */
00206 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
00207 # include <bits/syslog.h>
00208 #endif
00209 #ifdef __LDBL_COMPAT
00210 # include <bits/syslog-ldbl.h>
00211 #endif
00212 
00213 __END_DECLS
00214 
00215 #endif /* sys/syslog.h */