stdout output should just be WARN - put INFO in to a daily file

this is because stdout, in something like systemd, will mess up journalctl output.
This commit is contained in:
jesopo 2019-10-09 17:36:17 +01:00
parent 84ec6d812f
commit f721cf848a

View file

@ -29,7 +29,7 @@ class Log(object):
formatter = BitBotFormatter("%(asctime)s [%(levelname)s] %(message)s") formatter = BitBotFormatter("%(asctime)s [%(levelname)s] %(message)s")
stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(stdout_level) stdout_handler.setLevel(LEVELS["warn"])
stdout_handler.setFormatter(formatter) stdout_handler.setFormatter(formatter)
self.logger.addHandler(stdout_handler) self.logger.addHandler(stdout_handler)
@ -41,6 +41,13 @@ class Log(object):
trace_handler.setFormatter(formatter) trace_handler.setFormatter(formatter)
self.logger.addHandler(trace_handler) self.logger.addHandler(trace_handler)
info_path = os.path.join(location, "info.log")
info_handler = logging.handlers.TimedRotatingFileHandler(
info_path, when="midnight", backupCount=0)
info_handler.setLevel(LEVELS["info"])
info_handler.setFormatter(formatter)
self.logger.addHandler(info_handler)
warn_path = os.path.join(location, "warn.log") warn_path = os.path.join(location, "warn.log")
warn_handler = logging.FileHandler(warn_path) warn_handler = logging.FileHandler(warn_path)
warn_handler.setLevel(LEVELS["warn"]) warn_handler.setLevel(LEVELS["warn"])