@contextmanager
def controlled_logging(request, logger):
 default_level = None
 from_logout = _is_from_logout(request)
 if from_logout:
  default_level = logger.getEffectiveLevel()
  logger.setLevel(ERROR)
 try:
  (yield)
 finally:
  if from_logout:
   logger.setLevel(default_level)

@ contextmanager def controlled_logging ( request , logger ) : default_level = None from_logout = _is_from_logout ( request ) if from_logout : default_level = logger . getEffectiveLevel ( ) logger . setLevel ( ERROR ) try : ( yield ) finally : if from_logout : logger . setLevel ( default_level )
control the logging by changing loggers level if the request is from logout .