]> granicus.if.org Git - python/commitdiff
Closes #28524: added default level for logging.disable().
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 31 Dec 2016 11:40:11 +0000 (11:40 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 31 Dec 2016 11:40:11 +0000 (11:40 +0000)
Doc/library/logging.rst
Lib/logging/__init__.py
Lib/test/test_logging.py

index 6098878c1a12442aa0492e894c00509de6e0148a..d03cc50d87c2f0d6205dbeee1325796fee4e56df 100644 (file)
@@ -1023,7 +1023,7 @@ functions.
       handlers being added multiple times to the root logger, which can in turn
       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
    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
    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)
 
index 2590d6528f667c7d45745d8efabdd8737b4596c8..d886d35c12cee8a821b73a1d8b9f2e3ba5e08c69 100644 (file)
@@ -1889,7 +1889,7 @@ def log(level, msg, *args, **kwargs):
         basicConfig()
     root.log(level, msg, *args, **kwargs)
 
-def disable(level):
+def disable(level=CRITICAL):
     """
     Disable all logging calls of severity 'level' and below.
     """
index 08cdd7f3ebd8e7af18a060021804cd5e251ed4ad..7c5d1fd63cb3731c64376f2ec9b0c773ae6fbbcc 100644 (file)
@@ -3473,6 +3473,11 @@ class ModuleLevelMiscTest(BaseTest):
         logging.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):
         called = []
         support.patch(self, logging, 'basicConfig',