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