-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Logging getLogger Documentation Incomplete #127313
Comments
I don't think this is needed. We don't necessarily want those side effects to be documented. The root logger should not necessarily be named "root", it may change in the future and we may want to make that change invisible. Semantically speaking, it does not make sense to pass a falsey value to the function even if it's accepted at runtime. So I don't think we will document that. What we want to document is "the root logger can be retrieved via cc @vsajip |
Perhaps not needed... but, useful in guiding future examples. e.g.
https://docs.python.org/3/howto/logging-cookbook.html#dealing-with-handlers-that-block |
I think we can unify the examples then and avoid using '' as the name when possible. |
|
I'm not fond of documenting "root" because the runtime code checks for root.name which may change in the future or may be changed externally (IIRC you could technically get the root logger and directly change its name via root.name = ...). |
I like the combination of treating the falsy part as an implementation detail (@ZeroIntensity) and removing references to The name "root" is checked at runtime; however, the class |
You're right but the attribute is still without an underscore and people could think it's public so there might be code in the wild that changes the name (even if it's incorrect). If, in the future, we were to change the name, we don't necessarily want to expose the fact that "root" is the name. So, instead, I really think the root logger should be retrieved via |
Documentation
The latest
logging.getLogger
documentation is incomplete/inaccurate.Specifically,
"If no name is specified, return the root logger."
.To more accurately reflect the code...
Change it to
"If name is Falsy or 'root', return the root logger."
logging.getLogger
https://github.com/python/cpython/blob/3.13/Lib/logging/__init__.py#L2128Examples that will return root logger:
The text was updated successfully, but these errors were encountered: