10000 [doc] Clarify the nature of the root logger in the `logging` documentation by jkunimune · Pull Request #119440 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[doc] Clarify the nature of the root logger in the logging documentation #119440

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 4 commits into from
May 28, 2024
Merged
Changes from 1 commit
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
Next Next commit
clarify details of root logger
The way it's currently written, it's very confusing what the root logger's name is, because it's not explicitly stated anywhere (the how-to page says that its name "is printed as 'root'", which makes it sound like it's actually something else, but it's not it's just 'root'), and because it is stated that the logging hierarchy is based on period-separated names (this is true except for "root", and that exception isn't stated anywhere here).
  • Loading branch information
jkunimune authored May 22, 2024
commit c302708aaecce672bb7f0949626d7a42b1f967f5
7 changes: 4 additions & 3 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ The ``name`` is potentially a period-separated hierarchical value, like
Loggers that are further down in the hierarchical list are children of loggers
higher up in the list. For example, given a logger with a name of ``foo``,
loggers with names of ``foo.bar``, ``foo.bar.baz``, and ``foo.bam`` are all
descendants of ``foo``. The logger name hierarchy is analogous to the Python
descendants of ``foo``. In addition, all loggers are descendants of ``root``.
The logger name hierarchy is analogous to the Python
package hierarchy, and identical to it if you organise your loggers on a
per-module basis using the recommended construction
``logging.getLogger(__name__)``. That's because in a module, ``__name__``
Expand Down Expand Up @@ -1157,8 +1158,8 @@ functions.

.. function:: getLogger(name=None)

Return a logger with the specified name or, if name is ``None``, return a
logger which is the root logger of the hierarchy. If specified, the name is
Return a logger with the specified name or, if name is ``None``, return the
root logger of the hierarchy (equivalent to passing ``name='root'``). If specified, the name is
typically a dot-separated hierarchical name like *'a'*, *'a.b'* or *'a.b.c.d'*.
Choice of these names is entirely up to the developer who is using logging.

Expand Down
0