python日志格式化程序,它以多行日志消息和trackback为前缀。
multiline-log-formatter的Python项目详细描述
python日志格式化程序,它以多行日志消息和trackback为前缀。使日志更具可读性 回溯和多行日志消息。
- 免费软件:BSD许可证
基准
针对内置格式化程序logging.formatter中的pythons的基准测试。使用pytest基准完成基准测试, 下面的结果是在一个失败的新MacBookPro上运行,使用Python2.7。
应该注意的是,我们使用stringio作为流输出,因此我们应该期望结果更接近 更多类似于产品的设置,例如写入光盘。
安装
pip install multiline-log-formatter
用法
将此添加到dictconfig:
'formatters':{'default':{'()':'multiline_formatter.formatter.MultilineMessagesFormatter','format':'[%(levelname)s] %(message)s'},},
日志消息如下:
[ERROR] LOGGING_MESSAGE ... (49564:MainThread) ... (49564:MainThread) : Traceback (most recent call last): ... (49564:MainThread) : File "/Users/plauri/work/opensource/python-multiline-log-formatter/tests/test_multiline_formatter.py", line 112, in test_exception ... (49564:MainThread) : raise Exception('EXCEPTION_MESSAGE') ... (49564:MainThread) : Exception: EXCEPTION_MESSAGE
如果不喜欢默认值,可以通过扩展multileMessageFormatter对其进行自定义 多行标记。您也可以更改多行fmt,但请确保在格式化过程中包含%(消息)s。 弦。
开发
要运行所有测试,请运行:
tox
其他
这个项目sceleton是由ionelmc的pylibrarycookiecutter生成的。
更改日志
0.1.8(2016-01-15)
- pypi上的第一个版本。