blob: 3e5b166a2711c8aec9406e957134831e93dff8a2 [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}
Fred Drake06245ac1998-04-29 14:38:34 +000013Send the string \var{message} to the system logger. A trailing
14newline is added if necessary. Each message is tagged with a priority
15composed of a \var{facility} and a \var{level}. The optional
16\var{priority} argument, which defaults to \constant{LOG_INFO},
17determines the message priority. If the facility is not encoded in
18\var{priority} using logical-or (\code{LOG_INFO | LOG_USER}), the
19value given in the \function{openlog()} call is used.
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000020\end{funcdesc}
21
Fred Drake8ac34c21998-01-13 22:41:33 +000022\begin{funcdesc}{openlog}{ident\optional{, logopt\optional{, facility}}}
Fred Drake06245ac1998-04-29 14:38:34 +000023Logging options other than the defaults can be set by explicitly
24opening the log file with \function{openlog()} prior to calling
25\function{syslog()}. The defaults are (usually) \var{ident} =
26\code{'syslog'}, \var{logopt} = \code{0}, \var{facility} =
27\constant{LOG_USER}. The \var{ident} argument is a string which is
28prepended to every message. The optional \var{logopt} argument is a
29bit field - see below for possible values to combine. The optional
30\var{facility} argument sets the default facility for messages which
31do not have a facility explicitly encoded.
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000032\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
Fred Drake06245ac1998-04-29 14:38:34 +000040previous mask value. Calls to \function{syslog()} with a priority
41level not set in \var{maskpri} are ignored. The default is to log all
42priorities. The function \code{LOG_MASK(\var{pri})} calculates the
43mask for the individual priority \var{pri}. The function
44\code{LOG_UPTO(\var{pri})} calculates the mask for all priorities up
45to and including \var{pri}.
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000046\end{funcdesc}
47
48The module defines the following constants:
49
50\begin{description}
51
52\item[Priority levels (high to low):]
53
Fred Drake06245ac1998-04-29 14:38:34 +000054\constant{LOG_EMERG}, \constant{LOG_ALERT}, \constant{LOG_CRIT},
55\constant{LOG_ERR}, \constant{LOG_WARNING}, \constant{LOG_NOTICE},
56\constant{LOG_INFO}, \constant{LOG_DEBUG}.
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000057
58\item[Facilities:]
59
Fred Drake06245ac1998-04-29 14:38:34 +000060\constant{LOG_KERN}, \constant{LOG_USER}, \constant{LOG_MAIL},
61\constant{LOG_DAEMON}, \constant{LOG_AUTH}, \constant{LOG_LPR},
62\constant{LOG_NEWS}, \constant{LOG_UUCP}, \constant{LOG_CRON} and
63\constant{LOG_LOCAL0} to \constant{LOG_LOCAL7}.
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000064
65\item[Log options:]
66
Fred Drake06245ac1998-04-29 14:38:34 +000067\constant{LOG_PID}, \constant{LOG_CONS}, \constant{LOG_NDELAY},
68\constant{LOG_NOWAIT} and \constant{LOG_PERROR} if defined in
69\code{<syslog.h>}.
Guido van Rossumfbe34fa1995-10-09 20:49:57 +000070
71\end{description}