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