python日志库
spylogger的Python项目详细描述
通用python日志库。
文档:https://github.com/devstuff-io/spylogger
安装
基本伐木工人
这只安装spylogger,并将加载不需要外部依赖项的记录器。
pip install spylogger
漂亮的伐木工人
这将安装spylogger、pygments和pygments json,并加载基本的记录器和漂亮的记录器。
pip install spylogger[pretty]
配置
环境变量
Name | Description | Default |
---|---|---|
^{tt1}$ | The configured logger name. Available loggers:
| json-flat |
^{tt2}$ | The python log level. See the docs | WARNING |
^{tt3}$ | Flag for showing the ^{tt4}$ output. | True |
^{tt5}$ | A list of log record keys to put in the ^{tt4}$ section of the log message. Available Keys:
See the python docs |
|
漂亮的格式化程序样式
参见pygmentsdocumentation
环境变量
Name | Default |
---|---|
^{tt34}$ | autumn |
^{tt35}$ | monokai |
^{tt36}$ | fruity |
^{tt37}$ | default |
^{tt38}$ | vs |
可用样式
python -c "from pygments.styles import get_all_styles;print list(get_all_styles())"
用法
fromspyloggerimportget_logger# get_logger(name=SPY_LOG_LOGGER, log_level=SPY_LOG_LEVEL)logger=get_logger()logger.info({'string':'test Pretty info message.','int':42,'bool':True})
更多示例见example.py