diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-05-23 19:45:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 19:45:03 (GMT) |
commit | cea65730a75c06a34d00ffb29704cc7ac1a56b4b (patch) | |
tree | 9a3b6f3cce5eb8a18a19e00e4b9df3040156e0d7 | |
parent | f0950585a3723fd674964733ae3ced9217cf9d21 (diff) | |
download | cpython-cea65730a75c06a34d00ffb29704cc7ac1a56b4b.zip cpython-cea65730a75c06a34d00ffb29704cc7ac1a56b4b.tar.gz cpython-cea65730a75c06a34d00ffb29704cc7ac1a56b4b.tar.bz2 |
gh-92859: Doc: add info about logging.debug() calling basicConfig() (GH-93063) (GH-93151)
(cherry picked from commit 2176898308acafedf87a48d33f29645e79b9af86)
-rw-r--r-- | Doc/howto/logging.rst | 9 | ||||
-rw-r--r-- | Doc/library/logging.rst | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst index 4d76c27..9340062 100644 --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -178,10 +178,11 @@ following example:: raise ValueError('Invalid log level: %s' % loglevel) logging.basicConfig(level=numeric_level, ...) -The call to :func:`basicConfig` should come *before* any calls to :func:`debug`, -:func:`info` etc. As it's intended as a one-off simple configuration facility, -only the first call will actually do anything: subsequent calls are effectively -no-ops. +The call to :func:`basicConfig` should come *before* any calls to +:func:`debug`, :func:`info`, etc. Otherwise, those functions will call +:func:`basicConfig` for you with the default options. As it's intended as a +one-off simple configuration facility, only the first call will actually do +anything: subsequent calls are effectively no-ops. If you run the above script several times, the messages from successive runs are appended to the file *example.log*. If you want each run to start afresh, diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index b82b90b..3310c73 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -242,6 +242,10 @@ is the module's name in the Python package namespace. above example). In such circumstances, it is likely that specialized :class:`Formatter`\ s would be used with particular :class:`Handler`\ s. + If no handler is attached to this logger (or any of its ancestors, + taking into account the relevant :attr:`Logger.propagate` attributes), + the message will be sent to the handler set on :attr:`lastResort`. + .. versionchanged:: 3.2 The *stack_info* parameter was added. @@ -1038,6 +1042,10 @@ functions. above example). In such circumstances, it is likely that specialized :class:`Formatter`\ s would be used with particular :class:`Handler`\ s. + This function (as well as :func:`info`, :func:`warning`, :func:`error` and + :func:`critical`) will call :func:`basicConfig` if the root logger doesn't + have any handler attached. + .. versionchanged:: 3.2 The *stack_info* parameter was added. |