@contextmanager
def logger_disabled(name=None):
 log = logging.getLogger(name)
 was_disabled = log.disabled
 log.disabled = True
 try:
  (yield)
 finally:
  log.disabled = was_disabled

@ contextmanager def logger_disabled ( name = None ) : log = logging . getLogger ( name ) was_disabled = log . disabled log . disabled = True try : ( yield ) finally : log . disabled = was_disabled
temporarily disable a logger .