py-color-log
python 颜色缤纷的日志
运行环境
介绍
封装了 colorlog 使其更易用,效果如图:
其特点为:
- 默认的各等级颜色分配
- 默认的日志滚动配置(按天滚动,最多保留 7 天)
- 默认的第三方日志禁用:
requestschardet.charsetprober
- 灵活可控的配置
使用说明
在代码中引入 py-color-log 包即可:
from color_log.clog import log
log.debug('这是 DEBUG 日志,白色')
log.info('这是 INFO 日志,青绿')
log.warn('这是 WARN 日志,黄色')
log.error('这是 ERROR 日志,紫色')
try :
a = 1 / 0
except :
log.critical('这是 CRITICAL 日志,红色')
可以通过构造函数调整日志配置:
from color_log.clog import ColorLog
'''
[param] log_dir: 日志输出目录
[param] app_logs: 应用运行日志的名称字典,格式如 { name: min_level, ... }
[param] logfile_format: 输出日志文件的格式
[param] date_format: 输出日志文件的时间格式
[param] logcolors: 日志每个等级的颜色字典,格式如 { level: color, ... }
[param] rollday: 日志滚动间隔(单位:天)
[param] backupdays: 备份日志时长(单位:天)
[param] encoding: 日志编码
[param] debug: 是否打印 debug 日志
[param] thirdlist: 禁用的第三方日志列表
'''
log = ColorLog(
log_dir = './logs',
app_logs = {
'run.log': logging.INFO,
'err.log': logging.ERROR
},
logfile_format = '%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] - %(message)s',
date_format = '%Y-%m-%d %H:%M:%S',
log_colors = {
'DEBUG': 'white',
'INFO': 'cyan',
'WARNING': 'yellow',
'ERROR': 'purple',
'CRITICAL': 'red',
},
rollday = 1,
backupdays = 7,
encoding = 'utf-8',
debug = True,
thirdlist = [
'requests',
'chardet.charsetprober'
]
)
关于测试
详见 单元测试说明
赞助途径
| 支付宝 | 微信 |
|---|---|
版权声明
- Site: https://exp-blog.com
- Mail: 289065406@qq.com
Metadata
Release files for py-color-log 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py-color-log-1.0.4.tar.gz | 10.3 kB | Without provenance | Details for py-color-log-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_color_log-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for py_color_log-1.0.4-py3-none-any.whl |
Total release size: 16.5 kB
Release files / py-color-log-1.0.4.tar.gz
| Download URL | py-color-log-1.0.4.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fbe6afa214215b0f92fbb696afcb398f12f8b8bb1b3e0888d181df483ccaf13d
|
|
BLAKE2b-256 checksum How to use checksums |
828d4362bbfa62ad46d2e225b82f470f69d1716f00efc3ae5b4f2d8409f6f1c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / py_color_log-1.0.4-py3-none-any.whl
| Download URL | py_color_log-1.0.4-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
811f70991f8a596d38a6bb5b1ea4456ccf28adf30cb510f8dd1f03280919f42d
|
|
BLAKE2b-256 checksum How to use checksums |
ba3df3f007151b2265ac61d847c944dad247793c294263919dd1eadc15061697
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Security for py-color-log 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.