[Python-checkins] [3.10] gh-92859: Doc: add info about logging.debug() calling basicConfig() (GH-93063) (GH-93150)

vsajip webhook-mailer at python.org
Mon May 23 15:45:53 EDT 2022


https://github.com/python/cpython/commit/251104f12d0cebb997f26f8ca3dac48202c7456a
commit: 251104f12d0cebb997f26f8ca3dac48202c7456a
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vsajip <vinay_sajip at yahoo.co.uk>
date: 2022-05-23T20:45:44+01:00
summary:

[3.10] gh-92859: Doc: add info about logging.debug() calling basicConfig() (GH-93063) (GH-93150)

files:
M Doc/howto/logging.rst
M Doc/library/logging.rst

diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst
index fcc6bec768800..ff4e1d73a9653 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 b32af94e85d01..c9b049388e6d9 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.
 



More information about the Python-checkins mailing list