Need a way to pause all logging for massive Ursula tests.

pull/1451/head
jMyles 2019-11-08 22:58:12 -08:00
parent 946282da4d
commit a6d3e5841f
2 changed files with 12 additions and 0 deletions

View File

@ -433,6 +433,8 @@ class Learner:
# In some cases (seed nodes or other temp stored certs),
# this will update the filepath from the temp location to this one.
node.certificate_filepath = certificate_filepath
self.log.info(f"Saved TLS certificate for {node.nickname}: {certificate_filepath}")
try:

View File

@ -95,6 +95,16 @@ class GlobalLoggerSettings:
if was_already_going:
globalLogPublisher.addObserver(console_observer)
@classmethod
@contextmanager
def pause_all_logging_while(cls):
former_observers = tuple(globalLogPublisher._observers)
for observer in former_observers:
globalLogPublisher.removeObserver(observer)
yield
for observer in former_observers:
globalLogPublisher.addObserver(observer)
@classmethod
def start_text_file_logging(cls):
globalLogPublisher.addObserver(get_text_file_observer())