One-time initialization of loggers. See module docstring for more info.

def configure_logging():
  """One-time initialization of loggers. See module docstring for more info."""

  # Define the top-level logger.
  htf_logger = logging.getLogger(LOGGER_PREFIX)
  htf_logger.propagate = False
  htf_logger.setLevel(logging.DEBUG)

  # By default, don't print any logs to the CLI.
  if CLI_LOGGING_VERBOSITY == 0:
    htf_logger.addHandler(logging.NullHandler())
    return

  if CLI_LOGGING_VERBOSITY == 1:
    logging_level = logging.INFO
  else:
    logging_level = logging.DEBUG

  # Configure a handler to print to the CLI.
  cli_handler = KillableThreadSafeStreamHandler(stream=sys.stdout)
  cli_handler.setFormatter(CliFormatter())
  cli_handler.setLevel(logging_level)
  cli_handler.addFilter(MAC_FILTER)
  htf_logger.addHandler(cli_handler)

  # Suppress CLI logging if the --quiet flag is used, or while CLI_QUIET is set
  # in the console_output module.
  cli_handler.addFilter(console_output.CliQuietFilter())