@functions.CallOnce
def SetupLogger():
  """Configure logging for OpenHTF."""
  record_logger = logging.getLogger(RECORD_LOGGER)
  record_logger.propagate = False
  record_logger.setLevel(logging.DEBUG)
  record_logger.addHandler(logging.StreamHandler(stream=sys.stdout))

  logger = logging.getLogger(LOGGER_PREFIX)
  logger.propagate = False
  logger.setLevel(logging.DEBUG)
  formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
  if LOGFILE:
    try:
      cur_time = str(util.TimeMillis())
      file_handler = logging.FileHandler('%s.%s' % (LOGFILE, cur_time))
      file_handler.setFormatter(formatter)
      file_handler.setLevel(DEFAULT_LOGFILE_LEVEL.upper())
      file_handler.addFilter(MAC_FILTER)
      logger.addHandler(file_handler)
    except __HOLE__ as exception:
      print ('Failed to set up log file due to error: %s. '
             'Continuing anyway.' % exception)

  if not QUIET:
    console_handler = logging.StreamHandler(stream=sys.stderr)
    console_handler.setFormatter(formatter)
    console_handler.setLevel(DEFAULT_LEVEL.upper())
    console_handler.addFilter(MAC_FILTER)
    logger.addHandler(console_handler)
dataset/ETHPy150Open google/openhtf/openhtf/util/logs.py/SetupLogger