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