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