8000 bpo-37742: Return the root logger when logging.getLogger('root') is c… by vsajip · Pull Request #15077 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-37742: Return the root logger when logging.getLogger('root') is c… #15077

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 2 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
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
bpo-37742: Return the root logger when logging.getLogger('root') is c…
…alled.
  • Loading branch information
vsajip committed Aug 2, 2019
commit 6ce1c23549332a6130563578c0c1483defb39374
5 changes: 2 additions & 3 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2024,10 +2024,9 @@ def getLogger(name=None):

If no name is specified, return the root logger.
"""
if name:
return Logger.manager.getLogger(name)
else:
if not name or name == root.name:
return root
return Logger.manager.getLogger(name)

def critical(msg, *args, **kwargs):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The logging.getLogger() API now returns the root logger when passed the name
'root', whereas previously it returned a non-root logger named 'root'. This
could affect cases where user code explicitly wants a non-root logger named
'root', or instantiates a logger using logging.getLogger(__name__) in some
top-level module called 'root.py'.
0