2 :mod:`syslog` --- Unix syslog library routines
3 ==============================================
7 :synopsis: An interface to the Unix syslog library routines.
10 This module provides an interface to the Unix ``syslog`` library routines.
11 Refer to the Unix manual pages for a detailed description of the ``syslog``
14 The module defines the following functions:
17 .. function:: syslog([priority,] message)
19 Send the string *message* to the system logger. A trailing newline is added if
20 necessary. Each message is tagged with a priority composed of a *facility* and
21 a *level*. The optional *priority* argument, which defaults to
22 :const:`LOG_INFO`, determines the message priority. If the facility is not
23 encoded in *priority* using logical-or (``LOG_INFO | LOG_USER``), the value
24 given in the :func:`openlog` call is used.
27 .. function:: openlog(ident[, logopt[, facility]])
29 Logging options other than the defaults can be set by explicitly opening the log
30 file with :func:`openlog` prior to calling :func:`syslog`. The defaults are
31 (usually) *ident* = ``'syslog'``, *logopt* = ``0``, *facility* =
32 :const:`LOG_USER`. The *ident* argument is a string which is prepended to every
33 message. The optional *logopt* argument is a bit field - see below for possible
34 values to combine. The optional *facility* argument sets the default facility
35 for messages which do not have a facility explicitly encoded.
38 .. function:: closelog()
43 .. function:: setlogmask(maskpri)
45 Set the priority mask to *maskpri* and return the previous mask value. Calls to
46 :func:`syslog` with a priority level not set in *maskpri* are ignored. The
47 default is to log all priorities. The function ``LOG_MASK(pri)`` calculates the
48 mask for the individual priority *pri*. The function ``LOG_UPTO(pri)``
49 calculates the mask for all priorities up to and including *pri*.
51 The module defines the following constants:
53 Priority levels (high to low):
54 :const:`LOG_EMERG`, :const:`LOG_ALERT`, :const:`LOG_CRIT`, :const:`LOG_ERR`,
55 :const:`LOG_WARNING`, :const:`LOG_NOTICE`, :const:`LOG_INFO`,
59 :const:`LOG_KERN`, :const:`LOG_USER`, :const:`LOG_MAIL`, :const:`LOG_DAEMON`,
60 :const:`LOG_AUTH`, :const:`LOG_LPR`, :const:`LOG_NEWS`, :const:`LOG_UUCP`,
61 :const:`LOG_CRON` and :const:`LOG_LOCAL0` to :const:`LOG_LOCAL7`.
64 :const:`LOG_PID`, :const:`LOG_CONS`, :const:`LOG_NDELAY`, :const:`LOG_NOWAIT`
65 and :const:`LOG_PERROR` if defined in ``<syslog.h>``.