Commit 69d3828c authored by Kirill Smelkov's avatar Kirill Smelkov

*: tests: Always set logger.disabled = False for consistency

See previous commit for context: which had to fix
commit_from_wrong_partition this way because without `logger.disabled =
False` logging could not produce its output under Python 3.6.

Discussion1: https://github.com/zopefoundation/ZODB/pull/360#pullrequestreview-936832062
Discussion2: https://github.com/zopefoundation/ZODB/pull/360#issuecomment-1093710722
parent ae9c3f45
......@@ -49,7 +49,9 @@ logging:
>>> import logging, sys
>>> old_log_level = logging.getLogger().getEffectiveLevel()
>>> old_log_disabled = logging.getLogger().disabled
>>> logging.getLogger().setLevel(logging.DEBUG)
>>> logging.getLogger().disabled = False
>>> handler = logging.StreamHandler(sys.stdout)
>>> logging.getLogger().addHandler(handler)
......@@ -144,6 +146,7 @@ starting point, or just pick up where another iterator left off:
>>> it.close()
>>> logging.getLogger().setLevel(old_log_level)
>>> logging.getLogger().disabled = old_log_disabled
>>> logging.getLogger().removeHandler(handler)
......
......@@ -176,6 +176,8 @@ Make sure we can restore:
>>> logger = logging.getLogger('ZODB.FileStorage')
>>> logger.setLevel(logging.DEBUG)
>>> logger.addHandler(handler)
>>> log_disabled = logger.disabled
>>> logger.disabled = False
>>> index, pos, tid = fs._restore_index()
>>> index.items() == fs._index.items()
True
......@@ -186,6 +188,7 @@ cleanup
>>> fs.close()
>>> logger.setLevel(logging.NOTSET)
>>> logger.removeHandler(handler)
>>> logger.disabled = log_disabled
>>> sys.setrecursionlimit(old_limit)
"""
......
......@@ -83,6 +83,7 @@ class Handler(logging.Handler):
def setLoggerLevel(self, level=1):
self.level = level
self.oldlevels = {}
self.olddisabled = {}
def emit(self, record):
self.records.append(record)
......@@ -94,13 +95,16 @@ class Handler(logging.Handler):
for name in self.names:
logger = logging.getLogger(name)
self.oldlevels[name] = logger.level
self.olddisabled[name] = logger.disabled
logger.setLevel(self.level)
logger.disabled = False
logger.addHandler(self)
def uninstall(self):
for name in self.names:
logger = logging.getLogger(name)
logger.setLevel(self.oldlevels[name])
logger.disabled = self.olddisabled[name]
logger.removeHandler(self)
def __str__(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment