blob: c4c6166ac259b8c2bb7c7a709f6f5d01431c5672 [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Built-in Module \module{syslog}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-syslog}
Guido van Rossumfbe34fa1995-10-09 20:49:57 +00003\bimodindex{syslog}
4
Fred Drake8ac34c21998-01-13 22:41:33 +00005This module provides an interface to the \UNIX{} \code{syslog} library
Guido van Rossumfbe34fa1995-10-09 20:49:57 +00006routines. Refer to the \UNIX{} manual pages for a detailed description
7of the \code{syslog} facility.
8
9The module defines the following functions:
10
Fred Drake92796d11997-11-30 05:27:26 +000011
Fred Drakecce10901998-03-17 06:33:25 +000012\begin{funcdesc}{syslog}{\optional{priority,} message}
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000013Send the string \var{message} to the system logger.
14A trailing newline is added if necessary.
15Each message is tagged with a priority composed of a \var{facility} and
16a \var{level}.
17The optional \var{priority} argument, which defaults to
18\code{(LOG_USER | LOG_INFO)}, determines the message priority.
19\end{funcdesc}
20
Fred Drake8ac34c21998-01-13 22:41:33 +000021\begin{funcdesc}{openlog}{ident\optional{, logopt\optional{, facility}}}
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000022Logging options other than the defaults can be set by explicitly opening
23the log file with \code{openlog()} prior to calling \code{syslog()}.
24The defaults are (usually) \var{ident} = \samp{syslog}, \var{logopt} = 0,
25\var{facility} = \code{LOG_USER}.
26The \var{ident} argument is a string which is prepended to every message.
27The optional \var{logopt} argument is a bit field - see below for possible
28values to combine.
29The optional \var{facility} argument sets the default facility for messages
30which do not have a facility explicitly encoded.
31\end{funcdesc}
32
33\begin{funcdesc}{closelog}{}
34Close the log file.
35\end{funcdesc}
36
37\begin{funcdesc}{setlogmask}{maskpri}
38This function set the priority mask to \var{maskpri} and returns the
39previous mask value.
40Calls to \code{syslog} with a priority level not set in \var{maskpri}
41are ignored.
42The default is to log all priorities.
43The function \code{LOG_MASK(\var{pri})} calculates the mask for the
44individual priority \var{pri}.
45The function \code{LOG_UPTO(\var{pri})} calculates the mask for all priorities
46up to and including \var{pri}.
47\end{funcdesc}
48
49The module defines the following constants:
50
51\begin{description}
52
53\item[Priority levels (high to low):]
54
55\code{LOG_EMERG}, \code{LOG_ALERT}, \code{LOG_CRIT}, \code{LOG_ERR},
56\code{LOG_WARNING}, \code{LOG_NOTICE}, \code{LOG_INFO}, \code{LOG_DEBUG}.
57
58\item[Facilities:]
59
60\code{LOG_KERN}, \code{LOG_USER}, \code{LOG_MAIL}, \code{LOG_DAEMON},
61\code{LOG_AUTH}, \code{LOG_LPR}, \code{LOG_NEWS}, \code{LOG_UUCP},
62\code{LOG_CRON} and \code{LOG_LOCAL0} to \code{LOG_LOCAL7}.
63
64\item[Log options:]
65
66\code{LOG_PID}, \code{LOG_CONS}, \code{LOG_NDELAY}, \code{LOG_NOWAIT}
67and \code{LOG_PERROR} if defined in \file{syslog.h}.
68
69\end{description}