Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{syslog} --- |
| 2 | \UNIX{} syslog library routines.} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | \declaremodule{builtin}{syslog} |
| 4 | |
| 5 | \modulesynopsis{An interface to the \UNIX{} syslog library routines.} |
| 6 | |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 7 | |
Fred Drake | 8ac34c2 | 1998-01-13 22:41:33 +0000 | [diff] [blame] | 8 | This module provides an interface to the \UNIX{} \code{syslog} library |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 9 | routines. Refer to the \UNIX{} manual pages for a detailed description |
| 10 | of the \code{syslog} facility. |
| 11 | |
| 12 | The module defines the following functions: |
| 13 | |
Fred Drake | 92796d1 | 1997-11-30 05:27:26 +0000 | [diff] [blame] | 14 | |
Fred Drake | cce1090 | 1998-03-17 06:33:25 +0000 | [diff] [blame] | 15 | \begin{funcdesc}{syslog}{\optional{priority,} message} |
Fred Drake | 06245ac | 1998-04-29 14:38:34 +0000 | [diff] [blame] | 16 | Send the string \var{message} to the system logger. A trailing |
| 17 | newline is added if necessary. Each message is tagged with a priority |
| 18 | composed of a \var{facility} and a \var{level}. The optional |
| 19 | \var{priority} argument, which defaults to \constant{LOG_INFO}, |
| 20 | determines the message priority. If the facility is not encoded in |
| 21 | \var{priority} using logical-or (\code{LOG_INFO | LOG_USER}), the |
| 22 | value given in the \function{openlog()} call is used. |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 23 | \end{funcdesc} |
| 24 | |
Fred Drake | 8ac34c2 | 1998-01-13 22:41:33 +0000 | [diff] [blame] | 25 | \begin{funcdesc}{openlog}{ident\optional{, logopt\optional{, facility}}} |
Fred Drake | 06245ac | 1998-04-29 14:38:34 +0000 | [diff] [blame] | 26 | Logging options other than the defaults can be set by explicitly |
| 27 | opening 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 |
| 31 | prepended to every message. The optional \var{logopt} argument is a |
| 32 | bit field - see below for possible values to combine. The optional |
| 33 | \var{facility} argument sets the default facility for messages which |
| 34 | do not have a facility explicitly encoded. |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 35 | \end{funcdesc} |
| 36 | |
| 37 | \begin{funcdesc}{closelog}{} |
| 38 | Close the log file. |
| 39 | \end{funcdesc} |
| 40 | |
| 41 | \begin{funcdesc}{setlogmask}{maskpri} |
| 42 | This function set the priority mask to \var{maskpri} and returns the |
Fred Drake | 06245ac | 1998-04-29 14:38:34 +0000 | [diff] [blame] | 43 | previous mask value. Calls to \function{syslog()} with a priority |
| 44 | level not set in \var{maskpri} are ignored. The default is to log all |
| 45 | priorities. The function \code{LOG_MASK(\var{pri})} calculates the |
| 46 | mask for the individual priority \var{pri}. The function |
| 47 | \code{LOG_UPTO(\var{pri})} calculates the mask for all priorities up |
| 48 | to and including \var{pri}. |
Guido van Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 49 | \end{funcdesc} |
| 50 | |
| 51 | The module defines the following constants: |
| 52 | |
| 53 | \begin{description} |
| 54 | |
| 55 | \item[Priority levels (high to low):] |
| 56 | |
Fred Drake | 06245ac | 1998-04-29 14:38:34 +0000 | [diff] [blame] | 57 | \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 Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 60 | |
| 61 | \item[Facilities:] |
| 62 | |
Fred Drake | 06245ac | 1998-04-29 14:38:34 +0000 | [diff] [blame] | 63 | \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 Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 67 | |
| 68 | \item[Log options:] |
| 69 | |
Fred Drake | 06245ac | 1998-04-29 14:38:34 +0000 | [diff] [blame] | 70 | \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 Rossum | fbe34fa | 1995-10-09 20:49:57 +0000 | [diff] [blame] | 73 | |
| 74 | \end{description} |