Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ydf0509 committed Sep 11, 2021
1 parent e87276e commit c75104c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions nb_log/nb_log_config_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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不指定日志模板,则默认选择第几个模板
2 changes: 1 addition & 1 deletion tests/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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是天蓝色,日志正常')
Expand Down

0 comments on commit c75104c

Please sign in to comment.