diff --git a/bin/main.py b/bin/main.py index 8c30b14..e8fa687 100644 --- a/bin/main.py +++ b/bin/main.py @@ -44,7 +44,7 @@ class Game: self.client_log_config = self.log_config['client'] self.client_logger = logging.getLogger('client') self.client_fmt = logging.Formatter( - fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s", + fmt=self.client_log_config['fmt'], datefmt=self.client_log_config['date_fmt']) self.client_stream_handler = logging.StreamHandler() self.client_stream_handler.setLevel(self.client_log_config['level']) @@ -54,7 +54,7 @@ class Game: self.server_log_config = self.log_config['server'] self.server_logger = logging.getLogger('server') self.server_fmt = logging.Formatter( - fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s", + fmt=self.server_log_config['fmt'], datefmt=self.server_log_config['date_fmt']) self.server_stream_handler = logging.StreamHandler() self.server_stream_handler.setLevel(self.server_log_config['level']) @@ -62,8 +62,8 @@ class Game: self.server_logger.addHandler(self.server_stream_handler) # file logger self.log_formatter = logging.Formatter( - fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s", - datefmt=self.log_config['date_fmt']) + fmt=self.log_file_config['fmt'], + datefmt=self.log_file_config['date_fmt']) # client and server self.client = client.RenderThread( self.client_logger, self.dicts, self.lists, net_mode='local') diff --git a/configs/logging.json5 b/configs/logging.json5 index 7d3881c..c6f38ac 100644 --- a/configs/logging.json5 +++ b/configs/logging.json5 @@ -2,20 +2,24 @@ 'server': { 'level': 'DEBUG', // option: CRITICAL ERROR WARNING INFO DEBUG - 'fmt': '', - // format + 'fmt': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s', + // format of log 'date_fmt': '%Y-%m-%d %H-%M-%S', // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime }, 'client': { 'level': 'DEBUG', // option: CRITICAL ERROR WARNING INFO DEBUG + 'fmt': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s', + // format of log 'date_fmt': '%Y-%m-%d %H-%M-%S', // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime }, 'file': { 'level': 'DEBUG', // option: CRITICAL ERROR WARNING INFO DEBUG + 'fmt': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s', + // format of log 'date_fmt': '%Y-%m-%d %H-%M-%S', // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime 'filename': {