def setup_temp_logger(log_level='error'):
 if is_temp_logging_configured():
  logging.getLogger(__name__).warning('Temporary logging is already configured')
  return
 if (log_level is None):
  log_level = 'warning'
 level = LOG_LEVELS.get(log_level.lower(), logging.ERROR)
 handler = None
 for handler in logging.root.handlers:
  if (handler in (LOGGING_NULL_HANDLER, LOGGING_STORE_HANDLER)):
   continue
  if (not hasattr(handler, 'stream')):
   continue
  if (handler.stream is sys.stderr):
   break
 else:
  handler = LOGGING_TEMP_HANDLER
 handler.setLevel(level)
 formatter = logging.Formatter('[%(levelname)-8s] %(message)s', datefmt='%H:%M:%S')
 handler.setFormatter(formatter)
 logging.root.addHandler(handler)
 if (LOGGING_NULL_HANDLER is not None):
  LOGGING_NULL_HANDLER.sync_with_handlers([handler])
 else:
  logging.getLogger(__name__).debug("LOGGING_NULL_HANDLER is already None, can't sync messages with it")
 __remove_null_logging_handler()
 global __TEMP_LOGGING_CONFIGURED
 __TEMP_LOGGING_CONFIGURED = True

def setup_temp_logger ( log_level = 'error' ) : if is_temp_logging_configured ( ) : logging . getLogger ( __name__ ) . warning ( 'Temporary logging is already configured' ) return if ( log_level is None ) : log_level = 'warning' level = LOG_LEVELS . get ( log_level . lower ( ) , logging . ERROR ) handler = None for handler in logging . root . handlers : if ( handler in ( LOGGING_NULL_HANDLER , LOGGING_STORE_HANDLER ) ) : continue if ( not hasattr ( handler , 'stream' ) ) : continue if ( handler . stream is sys . stderr ) : break else : handler = LOGGING_TEMP_HANDLER handler . setLevel ( level ) formatter = logging . Formatter ( '[%(levelname)-8s] %(message)s' , datefmt = '%H:%M:%S' ) handler . setFormatter ( formatter ) logging . root . addHandler ( handler ) if ( LOGGING_NULL_HANDLER is not None ) : LOGGING_NULL_HANDLER . sync_with_handlers ( [ handler ] ) else : logging . getLogger ( __name__ ) . debug ( "LOGGING_NULL_HANDLER is already None, can't sync messages with it" ) __remove_null_logging_handler ( ) global __TEMP_LOGGING_CONFIGURED __TEMP_LOGGING_CONFIGURED = True
setup the temporary console logger .