diff options
Diffstat (limited to 'Doc/library/logging.rst')
-rw-r--r-- | Doc/library/logging.rst | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index 6e809cd..c5997ef 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -420,6 +420,13 @@ You can see that the config file approach has a few advantages over the Python code approach, mainly separation of configuration and code and the ability of noncoders to easily modify the logging properties. +Note that the class names referenced in config files need to be either relative +to the logging module, or absolute values which can be resolved using normal +import mechanisms. Thus, you could use either `handlers.WatchedFileHandler` +(relative to the logging module) or `mypackage.mymodule.MyHandler` (for a +class defined in package `mypackage` and module `mymodule`, where `mypackage` +is available on the Python import path). + .. _library-config: Configuring Logging for a Library @@ -1849,6 +1856,11 @@ timed intervals. The extensions are date-and-time based, using the strftime format ``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on the rollover interval. + + When computing the next rollover time for the first time (when the handler + is created), the last modification time of an existing log file, or else + the current time, is used to compute when the next rotation will occur. + If the *utc* argument is true, times in UTC will be used; otherwise local time is used. @@ -2401,6 +2413,28 @@ module, you may not be able to use logging from within such handlers. This is because lock implementations in the :mod:`threading` module are not always re-entrant, and so cannot be invoked from such signal handlers. + +Integration with the warnings module +------------------------------------ + +The :func:`captureWarnings` function can be used to integrate :mod:`logging` +with the :mod:`warnings` module. + +.. function:: captureWarnings(capture) + + This function is used to turn the capture of warnings by logging on and + off. + + If `capture` is `True`, warnings issued by the :mod:`warnings` module + will be redirected to the logging system. Specifically, a warning will be + formatted using :func:`warnings.formatwarning` and the resulting string + logged to a logger named "py.warnings" with a severity of `WARNING`. + + If `capture` is `False`, the redirection of warnings to the logging system + will stop, and warnings will be redirected to their original destinations + (i.e. those in effect before `captureWarnings(True)` was called). + + Configuration ------------- |