def _restore_logging(log_name='flocker.test'):
 def decorator(function):
  @wraps(function)
  def wrapper(self):
   def restore_logger(logger, level, handlers):
    logger.setLevel(level)
    for handler in logger.handlers[:]:
     logger.removeHandler(handler)
    for handler in handlers:
     logger.addHandler(handler)
   logger = logging.getLogger(log_name)
   self.addCleanup(restore_logger, logger, logger.getEffectiveLevel(), logger.handlers[:])
   return function(self, log_name)
  return wrapper
 return decorator

def _restore_logging ( log_name = 'flocker.test' ) : def decorator ( function ) : @ wraps ( function ) def wrapper ( self ) : def restore_logger ( logger , level , handlers ) : logger . setLevel ( level ) for handler in logger . handlers [ : ] : logger . removeHandler ( handler ) for handler in handlers : logger . addHandler ( handler ) logger = logging . getLogger ( log_name ) self . addCleanup ( restore_logger , logger , logger . getEffectiveLevel ( ) , logger . handlers [ : ] ) return function ( self , log_name ) return wrapper return decorator
save and restore a logging configuration .