Kaydet (Commit) f0a95eca authored tarafından Vinay Sajip's avatar Vinay Sajip

Saved and restored logging._handlerList at the same time as saving/restoring logging._handlers.

üst 05110aae
...@@ -467,6 +467,7 @@ def test4(): ...@@ -467,6 +467,7 @@ def test4():
sys.stdout.write('config%d: ' % i) sys.stdout.write('config%d: ' % i)
loggerDict = logging.getLogger().manager.loggerDict loggerDict = logging.getLogger().manager.loggerDict
saved_handlers = logging._handlers.copy() saved_handlers = logging._handlers.copy()
saved_handler_list = logging._handlerList[:]
saved_loggers = loggerDict.copy() saved_loggers = loggerDict.copy()
try: try:
fn = tempfile.mktemp(".ini") fn = tempfile.mktemp(".ini")
...@@ -484,6 +485,7 @@ def test4(): ...@@ -484,6 +485,7 @@ def test4():
finally: finally:
logging._handlers.clear() logging._handlers.clear()
logging._handlers.update(saved_handlers) logging._handlers.update(saved_handlers)
logging._handlerList = saved_handler_list
loggerDict = logging.getLogger().manager.loggerDict loggerDict = logging.getLogger().manager.loggerDict
loggerDict.clear() loggerDict.clear()
loggerDict.update(saved_loggers) loggerDict.update(saved_loggers)
...@@ -526,6 +528,7 @@ class FriendlyFormatter (logging.Formatter): ...@@ -526,6 +528,7 @@ class FriendlyFormatter (logging.Formatter):
def test5(): def test5():
loggerDict = logging.getLogger().manager.loggerDict loggerDict = logging.getLogger().manager.loggerDict
saved_handlers = logging._handlers.copy() saved_handlers = logging._handlers.copy()
saved_handler_list = logging._handlerList[:]
saved_loggers = loggerDict.copy() saved_loggers = loggerDict.copy()
try: try:
fn = tempfile.mktemp(".ini") fn = tempfile.mktemp(".ini")
...@@ -541,6 +544,7 @@ def test5(): ...@@ -541,6 +544,7 @@ def test5():
finally: finally:
logging._handlers.clear() logging._handlers.clear()
logging._handlers.update(saved_handlers) logging._handlers.update(saved_handlers)
logging._handlerList = saved_handler_list
loggerDict = logging.getLogger().manager.loggerDict loggerDict = logging.getLogger().manager.loggerDict
loggerDict.clear() loggerDict.clear()
loggerDict.update(saved_loggers) loggerDict.update(saved_loggers)
......
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