修改日志输出格式,降低代码重复率。

This commit is contained in:
shmilylty
2019-08-03 21:21:48 +08:00
parent 6241dd16db
commit 439fc9aa8e
55 changed files with 272 additions and 443 deletions
+7 -3
View File
@@ -152,7 +152,11 @@ subdomains_common = {'i', 'w', 'm', 'en', 'us', 'zh', 'w3', 'app', 'bbs', 'web',
'data', 'help', 'live', 'mall', 'blogs', 'files', 'forum', 'store', 'mobile'}
# 日志配置
log_fmt = '<light-green>{time:HH:mm:ss,SSS}</light-green> ' \
stdout_fmt = '<light-green>{time:HH:mm:ss,SSS}</light-green> ' \
'[<level>{level: <5}</level>] ' \
'<blue>{module}</blue>:<cyan>{line}</cyan> - ' \
'<level>{message}</level>'
logfile_fmt = '<light-green>{time:YYYY-MM-DD HH:mm:ss,SSS}</light-green> ' \
'[<level>{level: <5}</level>] ' \
'<cyan>{process.name}</cyan>:<cyan>{thread.name: <10}</cyan> | ' \
'<blue>{module}</blue>.<blue>{function}</blue>:<blue>{line}</blue> - ' \
@@ -168,8 +172,8 @@ logger.level(name='ALERT', no=30, color='<yellow><bold>', icon='⚠️')
logger.level(name='ERROR', no=40, color='<red><bold>', icon='❌️')
logger.level(name='FATAL', no=50, color='<RED><bold>', icon='☠️')
logger.add(sys.stdout, level='INFOR', format=log_fmt, enqueue=True)
logger.add(log_path, level='TRACE', format=log_fmt, enqueue=True, encoding='utf-8')
logger.add(sys.stdout, level='INFOR', format=stdout_fmt, enqueue=True)
logger.add(log_path, level='TRACE', format=logfile_fmt, enqueue=True, encoding='utf-8')
# 调试模式
# import urllib3