first commit

This commit is contained in:
2020-11-03 18:30:14 -08:00
commit 31d8522470
1881 changed files with 345408 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import logging
def setup(hub, conf):
"""
Given the configuration data set up the logger
"""
# Use the saved root logger
root = logging.getLogger()
raw_level = conf["log_level"].strip().lower()
if raw_level.isdigit():
hub.log.INT_LEVEL = int(raw_level)
else:
hub.log.INT_LEVEL = hub.log.LEVEL.get(raw_level, root.level)
root.setLevel(hub.log.INT_LEVEL)
cf = logging.Formatter(fmt=conf["log_fmt_console"], datefmt=conf["log_datefmt"])
ch = logging.StreamHandler()
ch.setLevel(hub.log.INT_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.setFormatter(ff)
root.addHandler(fh)