mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Closes #28524: added default level for logging.disable().
This commit is contained in:
parent
8e9c42e8e8
commit
d489ac9102
3 changed files with 15 additions and 2 deletions
|
@ -1023,7 +1023,7 @@ functions.
|
||||||
handlers being added multiple times to the root logger, which can in turn
|
handlers being added multiple times to the root logger, which can in turn
|
||||||
lead to multiple messages for the same event.
|
lead to multiple messages for the same event.
|
||||||
|
|
||||||
.. function:: disable(lvl)
|
.. function:: disable(lvl=CRITICAL)
|
||||||
|
|
||||||
Provides an overriding level *lvl* for all loggers which takes precedence over
|
Provides an overriding level *lvl* for all loggers which takes precedence over
|
||||||
the logger's own level. When the need arises to temporarily throttle logging
|
the logger's own level. When the need arises to temporarily throttle logging
|
||||||
|
@ -1036,6 +1036,14 @@ functions.
|
||||||
overriding level, so that logging output again depends on the effective
|
overriding level, so that logging output again depends on the effective
|
||||||
levels of individual loggers.
|
levels of individual loggers.
|
||||||
|
|
||||||
|
Note that if you have defined any custom logging level higher than
|
||||||
|
``CRITICAL`` (this is not recommended), you won't be able to rely on the
|
||||||
|
default value for the *lvl* parameter, but will have to explicitly supply a
|
||||||
|
suitable value.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.7
|
||||||
|
The *lvl* parameter was defaulted to level ``CRITICAL``. See Issue
|
||||||
|
#28524 for more information about this change.
|
||||||
|
|
||||||
.. function:: addLevelName(lvl, levelName)
|
.. function:: addLevelName(lvl, levelName)
|
||||||
|
|
||||||
|
|
|
@ -1889,7 +1889,7 @@ def log(level, msg, *args, **kwargs):
|
||||||
basicConfig()
|
basicConfig()
|
||||||
root.log(level, msg, *args, **kwargs)
|
root.log(level, msg, *args, **kwargs)
|
||||||
|
|
||||||
def disable(level):
|
def disable(level=CRITICAL):
|
||||||
"""
|
"""
|
||||||
Disable all logging calls of severity 'level' and below.
|
Disable all logging calls of severity 'level' and below.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -3473,6 +3473,11 @@ class ModuleLevelMiscTest(BaseTest):
|
||||||
logging.disable(83)
|
logging.disable(83)
|
||||||
self.assertEqual(logging.root.manager.disable, 83)
|
self.assertEqual(logging.root.manager.disable, 83)
|
||||||
|
|
||||||
|
# test the default value introduced in 3.7
|
||||||
|
# (Issue #28524)
|
||||||
|
logging.disable()
|
||||||
|
self.assertEqual(logging.root.manager.disable, logging.CRITICAL)
|
||||||
|
|
||||||
def _test_log(self, method, level=None):
|
def _test_log(self, method, level=None):
|
||||||
called = []
|
called = []
|
||||||
support.patch(self, logging, 'basicConfig',
|
support.patch(self, logging, 'basicConfig',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue