From c75104c63da5f1c8de0c72dc8ce8d467e133e1ca Mon Sep 17 00:00:00 2001 From: ydf0509 Date: Sat, 11 Sep 2021 20:21:30 +0800 Subject: [PATCH] commit --- nb_log/nb_log_config_default.py | 2 ++ tests/example.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nb_log/nb_log_config_default.py b/nb_log/nb_log_config_default.py index 46d0da5..7a133fb 100644 --- a/nb_log/nb_log_config_default.py +++ b/nb_log/nb_log_config_default.py @@ -121,6 +121,8 @@ def add_fields(self, log_record, record, message_dict): "%Y-%m-%d %H:%M:%S"), # 对5改进,带进程和线程显示的日志模板。 10: logging.Formatter( '[p%(process)d_t%(thread)d] %(asctime)s - %(name)s - "%(filename)s:%(lineno)d" - %(levelname)s - %(message)s', "%Y-%m-%d %H:%M:%S"), # 对7改进,带进程和线程显示的日志模板。 + 11: logging.Formatter( + f'({computer_ip},{computer_name})-[p%(process)d_t%(thread)d] %(asctime)s - %(name)s - "%(filename)s:%(lineno)d" - %(levelname)s - %(message)s', "%Y-%m-%d %H:%M:%S"), # 对7改进,带进程和线程显示的日志模板以及ip 机器名字。 } FORMATTER_KIND = 5 # 如果get_logger_and_add_handlers不指定日志模板,则默认选择第几个模板 diff --git a/tests/example.py b/tests/example.py index 42c6d90..76d5a08 100644 --- a/tests/example.py +++ b/tests/example.py @@ -3,7 +3,7 @@ from nb_log import get_logger -logger = get_logger('lalala',log_filename='jinzhifengzhuang.log',formatter_template=10) +logger = get_logger('lalala',log_filename='jinzhifengzhuang.log',formatter_template=11) logger.debug(f'debug是绿色,说明是调试的,代码ok') logger.info('info是天蓝色,日志正常')