Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 1 | \section{Built-in Module \sectcode{syslog}} |
Guido van Rossum | e47da0a | 1997-07-17 16:34:52 +0000 | [diff] [blame] | 2 | \label{module-syslog} |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 3 | \bimodindex{syslog} |
| 4 | |
Fred Drake | 8ac34c2 | 1998-01-13 22:41:33 +0000 | [diff] [blame] | 5 | This module provides an interface to the \UNIX{} \code{syslog} library |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 6 | routines. Refer to the \UNIX{} manual pages for a detailed description |
| 7 | of the \code{syslog} facility. |
| 8 | |
| 9 | The module defines the following functions: |
| 10 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 11 | \setindexsubitem{(in module syslog)} |
Fred Drake | 92796d1 | 1997-11-30 05:27:26 +0000 | [diff] [blame] | 12 | |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 13 | \begin{funcdesc}{syslog}{\optional{priority\,} message} |
| 14 | Send the string \var{message} to the system logger. |
| 15 | A trailing newline is added if necessary. |
| 16 | Each message is tagged with a priority composed of a \var{facility} and |
| 17 | a \var{level}. |
| 18 | The optional \var{priority} argument, which defaults to |
| 19 | \code{(LOG_USER | LOG_INFO)}, determines the message priority. |
| 20 | \end{funcdesc} |
| 21 | |
Fred Drake | 8ac34c2 | 1998-01-13 22:41:33 +0000 | [diff] [blame] | 22 | \begin{funcdesc}{openlog}{ident\optional{, logopt\optional{, facility}}} |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 23 | Logging options other than the defaults can be set by explicitly opening |
| 24 | the log file with \code{openlog()} prior to calling \code{syslog()}. |
| 25 | The defaults are (usually) \var{ident} = \samp{syslog}, \var{logopt} = 0, |
| 26 | \var{facility} = \code{LOG_USER}. |
| 27 | The \var{ident} argument is a string which is prepended to every message. |
| 28 | The optional \var{logopt} argument is a bit field - see below for possible |
| 29 | values to combine. |
| 30 | The optional \var{facility} argument sets the default facility for messages |
| 31 | which do not have a facility explicitly encoded. |
| 32 | \end{funcdesc} |
| 33 | |
| 34 | \begin{funcdesc}{closelog}{} |
| 35 | Close the log file. |
| 36 | \end{funcdesc} |
| 37 | |
| 38 | \begin{funcdesc}{setlogmask}{maskpri} |
| 39 | This function set the priority mask to \var{maskpri} and returns the |
| 40 | previous mask value. |
| 41 | Calls to \code{syslog} with a priority level not set in \var{maskpri} |
| 42 | are ignored. |
| 43 | The default is to log all priorities. |
| 44 | The function \code{LOG_MASK(\var{pri})} calculates the mask for the |
| 45 | individual priority \var{pri}. |
| 46 | The function \code{LOG_UPTO(\var{pri})} calculates the mask for all priorities |
| 47 | up to and including \var{pri}. |
| 48 | \end{funcdesc} |
| 49 | |
| 50 | The 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} |
| 68 | and \code{LOG_PERROR} if defined in \file{syslog.h}. |
| 69 | |
| 70 | \end{description} |