面向人类的Python日志:丰富多彩、界面简洁、使用简单、日志友好。
friendlylog的Python项目详细描述
FriendlyLog:Python日志记录变得简单了
FriendlyLog是一个简单、丰富、用户友好、线程安全的日志程序,用于Python
(2
和3
)。在
安装
pip install friendlylog
使用
- 简单记录器
将生成以下日志(test.py
是文件名):
[07-Oct-19 11:06:06.107 in test.py - <module>: 3] DEBUG: debug message
[07-Oct-19 11:06:06.107 in test.py - <module>: 4] INFO: info message
[07-Oct-19 11:06:06.107 in test.py - <module>: 5] WARNING: warning message
[07-Oct-19 11:06:06.107 in test.py - <module>: 6] ERROR: error message
[07-Oct-19 11:06:06.107 in test.py - <module>: 7] CRITICAL: critical message
- 彩色测井仪
importloggingfromfriendlylogimportcolored_loggeraslog# Anything above or including DEBUG will be logged.log.setLevel(logging.DEBUG)log.debug("debug message")log.info("info message")log.warning("warning message")log.error("error message")log.critical("critical message")
将生成以下日志(test.py
是文件名):
贡献
- 在
friendlylog
下为新的记录器编写代码。它应该导出以下方法:setLevel(level)
debug(msg: string)
info(msg: string)
warning(msg: string)
error(msg: string)
critical(msg: string)
- 在
tests
下编写覆盖>92%
的单元测试。您可以在本地运行测试 使用以下命令:bash run_tests.sh
。确保新的记录器是线程安全的。也, 添加检查线程安全性的单元测试 - 提交包含更改的请求。在
- 项目
标签: