in pplbench/main.py [0:0]
def configure_logging(config: SimpleNamespace, output_dir: str) -> None:
"""
Configure logging based on `config.loglevel` and add a stream handler.
:param config: benchmark configuration
:output_dir: directory to save the output
"""
# set log level to INFO by default on root logger
logging.getLogger().setLevel("INFO")
# setup logging for all other requested loglevels
if hasattr(config, "loglevels"):
for key, val in config.loglevels.__dict__.items():
logging.getLogger(key).setLevel(getattr(logging, val))
# create a handler at the root level to display to stdout
# and another to write to a log file
for ch in [
logging.StreamHandler(sys.stdout),
logging.FileHandler(os.path.join(output_dir, "logging.txt"), encoding="utf-8"),
]:
formatter = logging.Formatter(LOG_FORMAT)
ch.setFormatter(formatter)
logging.getLogger().addHandler(ch)
LOGGER.debug(f"config - {str(config)}")