Skip to content

[3.9] bpo-35821: Add an example to Logger.propagate documentation. (GH-29841) (GH-29958) #29958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down