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