Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/syslog.rst

    r2 r391  
    1 
    21:mod:`syslog` --- Unix syslog library routines
    32==============================================
     
    1211facility.
    1312
     13This module wraps the system ``syslog`` family of routines.  A pure Python
     14library that can speak to a syslog server is available in the
     15:mod:`logging.handlers` module as :class:`SysLogHandler`.
     16
    1417The module defines the following functions:
    1518
    1619
    17 .. function:: syslog([priority,] message)
     20.. function:: syslog(message)
     21              syslog(priority, message)
    1822
    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.
     23   Send the string *message* to the system logger.  A trailing newline is added
     24   if necessary.  Each message is tagged with a priority composed of a
     25   *facility* and a *level*.  The optional *priority* argument, which defaults
     26   to :const:`LOG_INFO`, determines the message priority.  If the facility is
     27   not encoded in *priority* using logical-or (``LOG_INFO | LOG_USER``), the
     28   value given in the :func:`openlog` call is used.
     29
     30   If :func:`openlog` has not been called prior to the call to :func:`syslog`,
     31   ``openlog()`` will be called with no arguments.
    2532
    2633
    27 .. function:: openlog(ident[, logopt[, facility]])
     34.. function:: openlog([ident[, logoption[, facility]]])
    2835
    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   Logging options of subsequent :func:`syslog` calls can be set by calling
     37   :func:`openlog`.  :func:`syslog` will call :func:`openlog` with no arguments
     38   if the log is not currently open.
     39
     40   The optional *ident* keyword argument is a string which is prepended to every
     41   message, and defaults to ``sys.argv[0]`` with leading path components
     42   stripped.  The optional *logoption* keyword argument (default is 0) is a bit
     43   field -- see below for possible values to combine.  The optional *facility*
     44   keyword argument (default is :const:`LOG_USER`) sets the default facility for
     45   messages which do not have a facility explicitly encoded.
    3646
    3747
    3848.. function:: closelog()
    3949
    40    Close the log file.
     50   Reset the syslog module values and call the system library ``closelog()``.
     51
     52   This causes the module to behave as it does when initially imported.  For
     53   example, :func:`openlog` will be called on the first :func:`syslog` call (if
     54   :func:`openlog` hasn't already been called), and *ident* and other
     55   :func:`openlog` parameters are reset to defaults.
    4156
    4257
    4358.. function:: setlogmask(maskpri)
    4459
    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*.
     60   Set the priority mask to *maskpri* and return the previous mask value.  Calls
     61   to :func:`syslog` with a priority level not set in *maskpri* are ignored.
     62   The default is to log all priorities.  The function ``LOG_MASK(pri)``
     63   calculates the mask for the individual priority *pri*.  The function
     64   ``LOG_UPTO(pri)`` calculates the mask for all priorities up to and including
     65   *pri*.
    5066
    5167The module defines the following constants:
     
    5975   :const:`LOG_KERN`, :const:`LOG_USER`, :const:`LOG_MAIL`, :const:`LOG_DAEMON`,
    6076   :const:`LOG_AUTH`, :const:`LOG_LPR`, :const:`LOG_NEWS`, :const:`LOG_UUCP`,
    61    :const:`LOG_CRON` and :const:`LOG_LOCAL0` to :const:`LOG_LOCAL7`.
     77   :const:`LOG_CRON`, :const:`LOG_SYSLOG` and :const:`LOG_LOCAL0` to
     78   :const:`LOG_LOCAL7`.
    6279
    6380Log options:
     
    6582   and :const:`LOG_PERROR` if defined in ``<syslog.h>``.
    6683
     84
     85Examples
     86--------
     87
     88Simple example
     89~~~~~~~~~~~~~~
     90
     91A simple set of examples::
     92
     93   import syslog
     94
     95   syslog.syslog('Processing started')
     96   if error:
     97       syslog.syslog(syslog.LOG_ERR, 'Processing started')
     98
     99An example of setting some log options, these would include the process ID in
     100logged messages, and write the messages to the destination facility used for
     101mail logging::
     102
     103   syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL)
     104   syslog.syslog('E-mail processing initiated...')
Note: See TracChangeset for help on using the changeset viewer.