diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-02-19 23:53:17 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-02-19 23:53:17 (GMT) |
commit | 61afd2694bf6bff8c65a392aaf27c575d92b7eb9 (patch) | |
tree | 41366dc5c384f1c968d4ce0563a668083ae558b5 /Doc/library | |
parent | 74cbd664d280e75ce376b5757639f5d4ed098eac (diff) | |
download | cpython-61afd2694bf6bff8c65a392aaf27c575d92b7eb9.zip cpython-61afd2694bf6bff8c65a392aaf27c575d92b7eb9.tar.gz cpython-61afd2694bf6bff8c65a392aaf27c575d92b7eb9.tar.bz2 |
logging: Documented warnings module integration.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/logging.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index bca497f..d9824fd 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -2477,6 +2477,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 ------------- |