From 4e9ac95c057959bd0e7e4d8b34db2218dde7ce51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Mon, 15 Feb 2021 23:48:13 +0800 Subject: [PATCH] finally! logger fixed! --- bin/main.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bin/main.py b/bin/main.py index 15bda46..4621e4b 100644 --- a/bin/main.py +++ b/bin/main.py @@ -35,19 +35,15 @@ class Game: self.log_config = tools.config('configs/logging.json5', 'file') self.log_filename = 'logs/' + configs.name_handler(self.log_config['filename']['main'], self.log_config['filename']['formats']) - logging.basicConfig(level=logging.DEBUG, - format=self.log_config['fmt'], - datefmt=self.log_config['date_fmt']) self.root_logger_stream_handler = logging.StreamHandler() self.root_logger_stream_handler.setLevel(self.log_config['level']) - - logging.info('logger done') - self.root_logger_fmt = logging.Formatter(self.log_config['fmt'], self.log_config['date_fmt']) self.root_logger_stream_handler.setFormatter(self.root_logger_fmt) - self.root_logger_stream_handler.setLevel(self.log_config['level']) + self.root_logger_stream_handler.setLevel(tools.log_level(self.log_config['level'])) self.root_logger_file_handler = logging.FileHandler(self.log_filename) self.root_logger_file_handler.setFormatter(self.root_logger_fmt) + self.root_logger_file_handler.setLevel(tools.log_level(self.log_config['level'])) + logging.getLogger().setLevel(tools.log_level(self.log_config['level'])) logging.getLogger().addHandler(self.root_logger_stream_handler) logging.getLogger().addHandler(self.root_logger_file_handler)