Skip to content

[doc] Add a section on logging handler configuration order. (GH-101380) #101380

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
Jan 27, 2023
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
23 changes: 23 additions & 0 deletions Doc/library/logging.config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,29 @@ attribute ``baz`` set to ``'bozz'``.
configuration machinery, but set as attribute values as-is.


.. _handler-config-dict-order:

Handler configuration order
"""""""""""""""""""""""""""

Handlers are configured in alphabetical order of their keys, and a configured
handler replaces the configuration dictionary in (a working copy of) the
``handlers`` dictionary in the schema. If you use a construct such as
``cfg://handlers.foo``, then initially ``handlers['foo']`` points to the
configuration dictionary for the handler named ``foo``, and later (once that
handler has been configured) it points to the configured handler instance.
Thus, ``cfg://handlers.foo`` could resolve to either a dictionary or a handler
instance. In general, it is wise to name handlers in a way such that dependent
handlers are configured _after_ any handlers they depend on; that allows
something like ``cfg://handlers.foo`` to be used in configuring a handler that
depends on handler ``foo``. If that dependent handler were named ``bar``,
problems would result, because the configuration of ``bar`` would be attempted
before that of ``foo``, and ``foo`` would not yet have been configured.
However, if the dependent handler were named ``foobar``, it would be configured
after ``foo``, with the result that ``cfg://handlers.foo`` would resolve to
configured handler ``foo``, and not its configuration dictionary.


.. _logging-config-dict-externalobj:

Access to external objects
Expand Down