From 19bb1421215e0979cec66f21d9ca9261e48ed155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Wed, 22 Sep 2021 06:32:10 +0800 Subject: [PATCH] commit about v 0.5.2 release comming(no DEMO) --- Difficult_Rocket/main.py | 13 ++++++++++--- configs/lang/zh-CN.json5 | 1 + docs/update_logs.md | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Difficult_Rocket/main.py b/Difficult_Rocket/main.py index 7ebd248..7c00229 100644 --- a/Difficult_Rocket/main.py +++ b/Difficult_Rocket/main.py @@ -44,9 +44,16 @@ class Game: log_config = tools.config('configs/logger.json5') file_name = log_config['handlers']['file']['filename'] del log_config['handlers']['file']['datefmt'] - log_config['handlers']['file']['filename'] = file_name.format(self.start_time) - logging.config.dictConfig(log_config) - self.logger = logging.getLogger('main') + log_config['handlers']['file']['filename'] = f'logs/{file_name.format(self.start_time)}' + try: + logging.config.dictConfig(log_config) + self.logger = logging.getLogger('main') + except ValueError: + os.mkdir('logs') + logging.config.dictConfig(log_config) + self.logger = logging.getLogger('main') + self.logger.info(tr['main']['logger.mkdir']) + self.logger.info(tr['main']['logger.created']) # version check self.python_version_check() self.setup() diff --git a/configs/lang/zh-CN.json5 b/configs/lang/zh-CN.json5 index ec8764f..2541ee8 100644 --- a/configs/lang/zh-CN.json5 +++ b/configs/lang/zh-CN.json5 @@ -6,6 +6,7 @@ 'lang.language': '简 体 中 文 (zh-cn)', 'logger.language': '日志记录语言为:', 'logger.created': '日志处理器创建完成', + 'logger.mkdir': 'logs/文件夹不存在,已经新建文件夹', 'logger.main_done': '主日志处理器创建完成', 'logger.logfile_name': '日志文件文件名:', 'logger.logfile_level': '日志文件记录级别:', diff --git a/docs/update_logs.md b/docs/update_logs.md index d50b704..c527ed4 100644 --- a/docs/update_logs.md +++ b/docs/update_logs.md @@ -35,6 +35,7 @@ - (witch was `zh-CN`) - `crash` now have more information about multiprocess - add some unused read_input in `client` +- now when `logs/` is not found logger will info `logger.mkdir` ### DEBUG