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