Updated incorrect level-setting code to use setLevel(). (GH-16325)

This commit is contained in:
Vinay Sajip 2019-09-22 03:51:51 +01:00 committed by GitHub
parent b104ecbbaf
commit 1d094af716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2001-2016 by Vinay Sajip. All Rights Reserved. # Copyright 2001-2019 by Vinay Sajip. All Rights Reserved.
# #
# Permission to use, copy, modify, and distribute this software and its # Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, # documentation for any purpose and without fee is hereby granted,
@ -19,7 +19,7 @@ Configuration functions for the logging package for Python. The core package
is based on PEP 282 and comments thereto in comp.lang.python, and influenced is based on PEP 282 and comments thereto in comp.lang.python, and influenced
by Apache's log4j system. by Apache's log4j system.
Copyright (C) 2001-2016 Vinay Sajip. All Rights Reserved. Copyright (C) 2001-2019 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away! To use, simply 'import logging' and log away!
""" """
@ -173,7 +173,8 @@ def _handle_existing_loggers(existing, child_loggers, disable_existing):
for log in existing: for log in existing:
logger = root.manager.loggerDict[log] logger = root.manager.loggerDict[log]
if log in child_loggers: if log in child_loggers:
logger.level = logging.NOTSET if not isinstance(logger, logging.PlaceHolder):
logger.setLevel(logging.NOTSET)
logger.handlers = [] logger.handlers = []
logger.propagate = True logger.propagate = True
else: else:

View File

@ -4315,7 +4315,7 @@ class BasicConfigTest(unittest.TestCase):
logging._handlers.clear() logging._handlers.clear()
logging._handlers.update(self.saved_handlers) logging._handlers.update(self.saved_handlers)
logging._handlerList[:] = self.saved_handler_list logging._handlerList[:] = self.saved_handler_list
logging.root.level = self.original_logging_level logging.root.setLevel(self.original_logging_level)
def test_no_kwargs(self): def test_no_kwargs(self):
logging.basicConfig() logging.basicConfig()