1
0
forked from Hay1tsme/artemis

remove unnecessassary logging dup check

This commit is contained in:
Hay1tsme 2023-02-24 14:14:18 -05:00
parent cb227f9cf4
commit b31e739ecd

View File

@ -92,23 +92,21 @@ if __name__ == "__main__":
cfg.update(yaml.safe_load(open(f"{args.config}/core.yaml"))) cfg.update(yaml.safe_load(open(f"{args.config}/core.yaml")))
logger = logging.getLogger("core") logger = logging.getLogger("core")
if not hasattr(logger, "initialized"): log_fmt_str = "[%(asctime)s] Core | %(levelname)s | %(message)s"
log_fmt_str = "[%(asctime)s] Core | %(levelname)s | %(message)s" log_fmt = logging.Formatter(log_fmt_str)
log_fmt = logging.Formatter(log_fmt_str)
fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(cfg.server.log_dir, "core"), when="d", backupCount=10) fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(cfg.server.log_dir, "core"), when="d", backupCount=10)
fileHandler.setFormatter(log_fmt) fileHandler.setFormatter(log_fmt)
consoleHandler = logging.StreamHandler() consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(log_fmt) consoleHandler.setFormatter(log_fmt)
logger.addHandler(fileHandler) logger.addHandler(fileHandler)
logger.addHandler(consoleHandler) logger.addHandler(consoleHandler)
log_lv = logging.DEBUG if cfg.server.is_develop else logging.INFO log_lv = logging.DEBUG if cfg.server.is_develop else logging.INFO
logger.setLevel(log_lv) logger.setLevel(log_lv)
coloredlogs.install(level=log_lv, logger=logger, fmt=log_fmt_str) coloredlogs.install(level=log_lv, logger=logger, fmt=log_fmt_str)
logger.initialized = True
if not path.exists(cfg.server.log_dir): if not path.exists(cfg.server.log_dir):
mkdir(cfg.server.log_dir) mkdir(cfg.server.log_dir)