Files
basegame-vcko/python3-vckonline/lib/python3.8/site-packages/pop/mods/conf/log/basic.py
2020-11-03 18:30:14 -08:00

24 lines
729 B
Python

# Import python libs
import logging
import pop.hub
from typing import Any, Dict
def setup(hub: "pop.hub.Hub", conf: Dict[str, Any]):
"""
Given the configuration data set up the logger
"""
level = hub.conf.log.LEVELS.get(conf["log_level"].lower(), logging.INFO)
root = logging.getLogger("")
root.setLevel(level)
cf = logging.Formatter(fmt=conf["log_fmt_console"], datefmt=conf["log_datefmt"])
ch = logging.StreamHandler()
ch.setLevel(level)
ch.setFormatter(cf)
root.addHandler(ch)
ff = logging.Formatter(fmt=conf["log_fmt_console"], datefmt=conf["log_datefmt"])
fh = logging.FileHandler(conf["log_file"])
fh.setLevel(level)
fh.setFormatter(ff)
root.addHandler(fh)