[Python-checkins] bpo-35821: Add an example to Logger.propagate documentation. (GH-29841)

vsajip webhook-mailer at python.org
Tue Dec 7 06:15:54 EST 2021


https://github.com/python/cpython/commit/2bf551757e0a7e3cc6ce2ebed2178b82438ac6b5
commit: 2bf551757e0a7e3cc6ce2ebed2178b82438ac6b5
branch: main
author: Vinay Sajip <vinay_sajip at yahoo.co.uk>
committer: vsajip <vinay_sajip at yahoo.co.uk>
date: 2021-12-07T11:15:44Z
summary:

bpo-35821: Add an example to Logger.propagate documentation. (GH-29841)

files:
M Doc/library/logging.rst

diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index 3f3a8534f54d0..e7c64e5ba4036 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -80,6 +80,15 @@ is the module's name in the Python package namespace.
       If this evaluates to false, logging messages are not passed to the handlers
       of ancestor loggers.
 
+      Spelling it out with an example: If the propagate attribute of the logger named
+      `A.B.C` evaluates to true, any event logged to `A.B.C` via a method call such as
+      `logging.getLogger('A.B.C').error(...)` will [subject to passing that logger's
+      level and filter settings] be passed in turn to any handlers attached to loggers
+      named `A.B`, `A` and the root logger, after first being passed to any handlers
+      attached to `A.B.C`. If any logger in the chain `A.B.C`, `A.B`, `A` has its
+      `propagate` attribute set to false, then that is the last logger whose handlers
+      are offered the event to handle, and propagation stops at that point.
+
       The constructor sets this attribute to ``True``.
 
       .. note:: If you attach a handler to a logger *and* one or more of its



More information about the Python-checkins mailing list