blob: 549f26b00899f0d954722785e84bc1de4952a7bc [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001
2:mod:`syslog` --- Unix syslog library routines
3==============================================
4
5.. module:: syslog
6 :platform: Unix
7 :synopsis: An interface to the Unix syslog library routines.
8
9
10This module provides an interface to the Unix ``syslog`` library routines.
11Refer to the Unix manual pages for a detailed description of the ``syslog``
12facility.
13
14The module defines the following functions:
15
16
17.. function:: syslog([priority,] message)
18
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.
25
26
27.. function:: openlog(ident[, logopt[, facility]])
28
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.
36
37
38.. function:: closelog()
39
40 Close the log file.
41
42
43.. function:: setlogmask(maskpri)
44
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*.
50
51The module defines the following constants:
52
53Priority 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`,
56 :const:`LOG_DEBUG`.
57
58Facilities:
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`.
62
63Log options:
64 :const:`LOG_PID`, :const:`LOG_CONS`, :const:`LOG_NDELAY`, :const:`LOG_NOWAIT`
65 and :const:`LOG_PERROR` if defined in ``<syslog.h>``.
66