diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/logging/__init__.py | 3 | ||||
-rw-r--r-- | Lib/test/test_logging.py | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 509dae6..7efbc45 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1442,7 +1442,8 @@ class Logger(Filterer): c = c.parent if (found == 0): if lastResort: - lastResort.handle(record) + if record.levelno >= lastResort.level: + lastResort.handle(record) elif raiseExceptions and not self.manager.emittedNoHandlerWarning: sys.stderr.write("No handlers could be found for logger" " \"%s\"\n" % self.name) diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 5d84114..793d29b 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -2923,6 +2923,8 @@ class LastResortTest(BaseTest): old_raise_exceptions = logging.raiseExceptions try: sys.stderr = sio = io.StringIO() + root.debug('This should not appear') + self.assertEqual(sio.getvalue(), '') root.warning('This is your final chance!') self.assertEqual(sio.getvalue(), 'This is your final chance!\n') #No handlers and no last resort, so 'No handlers' message |