def setup_console_logger(log_level='error', log_format=None, date_format=None):
 if is_console_configured():
  logging.getLogger(__name__).warning('Console logging already configured')
  return
 __remove_temp_logging_handler()
 if (log_level is None):
  log_level = 'warning'
 level = LOG_LEVELS.get(log_level.lower(), logging.ERROR)
 setLogRecordFactory(SaltColorLogRecord)
 handler = None
 for handler in logging.root.handlers:
  if (handler is LOGGING_STORE_HANDLER):
   continue
  if (not hasattr(handler, 'stream')):
   continue
  if (handler.stream is sys.stderr):
   break
 else:
  handler = StreamHandler(sys.stderr)
 handler.setLevel(level)
 if (not log_format):
  log_format = '[%(levelname)-8s] %(message)s'
 if (not date_format):
  date_format = '%H:%M:%S'
 formatter = logging.Formatter(log_format, datefmt=date_format)
 handler.setFormatter(formatter)
 logging.root.addHandler(handler)
 global __CONSOLE_CONFIGURED
 global __LOGGING_CONSOLE_HANDLER
 __CONSOLE_CONFIGURED = True
 __LOGGING_CONSOLE_HANDLER = handler

def setup_console_logger ( log_level = 'error' , log_format = None , date_format = None ) : if is_console_configured ( ) : logging . getLogger ( __name__ ) . warning ( 'Console logging already configured' ) return __remove_temp_logging_handler ( ) if ( log_level is None ) : log_level = 'warning' level = LOG_LEVELS . get ( log_level . lower ( ) , logging . ERROR ) setLogRecordFactory ( SaltColorLogRecord ) handler = None for handler in logging . root . handlers : if ( handler is LOGGING_STORE_HANDLER ) : continue if ( not hasattr ( handler , 'stream' ) ) : continue if ( handler . stream is sys . stderr ) : break else : handler = StreamHandler ( sys . stderr ) handler . setLevel ( level ) if ( not log_format ) : log_format = '[%(levelname)-8s] %(message)s' if ( not date_format ) : date_format = '%H:%M:%S' formatter = logging . Formatter ( log_format , datefmt = date_format ) handler . setFormatter ( formatter ) logging . root . addHandler ( handler ) global __CONSOLE_CONFIGURED global __LOGGING_CONSOLE_HANDLER __CONSOLE_CONFIGURED = True __LOGGING_CONSOLE_HANDLER = handler
setup the console logger .