-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Open
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
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#L2128
def getLogger(name=None):
"""
Return a logger with the specified name, creating it if necessary.
If no name is specified, return the root logger.
"""
if not name or isinstance(name, str) and name == root.name:
return root
return Logger.manager.getLogger(name)
Examples that will return root logger:
logger = logging.getLogger()
logger = logging.getLogger("")
logger = logging.getLogger("root")
logger = logging.getLogger(None)
logger = logging.getLogger(False)
logger = logging.getLogger(0)
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo