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