diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2019-08-02 16:53:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-02 16:53:00 +0100 |
commit | cb65b3a4f484ce71dcb76a918af98c7015513025 (patch) | |
tree | 7f4e08a9ed98315e4fe5d0651f9344271db928a2 /Lib/logging | |
parent | bpo-36487: Make C-API docs clear about what the main interpreter is. (gh-12666) (diff) | |
download | cpython-cb65b3a4f484ce71dcb76a918af98c7015513025.tar.gz cpython-cb65b3a4f484ce71dcb76a918af98c7015513025.tar.bz2 cpython-cb65b3a4f484ce71dcb76a918af98c7015513025.zip |
bpo-37742: Return the root logger when logging.getLogger('root') is c… (#15077)
* bpo-37742: Return the root logger when logging.getLogger('root') is called.
* Added type check guard on logger name in logging.getLogger() and refined a test.
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 645e0b3c3a6..62a87a71b1a 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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 isinstance(name, str) and name == root.name: return root + return Logger.manager.getLogger(name) def critical(msg, *args, **kwargs): """ |