From f0a680abc6b09ddcd08ecdfcc5179448aa15c422 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 23 Aug 2023 15:49:02 +0800 Subject: [PATCH] fix logging --- app/log.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/log.py b/app/log.py index db030713..5f01abb4 100644 --- a/app/log.py +++ b/app/log.py @@ -22,8 +22,15 @@ file_handler = RotatingFileHandler(filename=settings.LOG_PATH / 'moviepilot.log' encoding='utf-8') file_handler.setLevel(logging.INFO) + # 定义日志输出格式 -formatter = logging.Formatter("%(levelname)s: %(asctime)s - %(filename)s - %(message)s") +class CustomFormatter(logging.Formatter): + def format(self, record): + record.levelname = record.levelname + ':' + return super().format(record) + + +formatter = CustomFormatter("%(levelname)-10s%(asctime)s - %(filename)s - %(message)s") console_handler.setFormatter(formatter) file_handler.setFormatter(formatter)