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