PyLog
一个基于 logbook 的彩色日志库,支持多种日志级别和日志文件自动分割。
安装
pip install liwancai-PyLog
快速使用
from LOG import log
log.Info("This is an info message")
log.Debug("This is a debug message")
log.Error("This is an error message")
log.Warn("This is a warning message")
log.Critical("This is a critical message")
日志级别
| 方法 | 级别 | 颜色 |
|---|---|---|
Info() |
INFO | 绿色 |
Debug() |
DEBUG | 青色 |
Error() |
ERROR | 红色 |
Warn() |
WARNING | 黄色 |
Critical() |
CRITICAL | 紫色 |
Notice() |
NOTICE | 橙色 |
Trace() |
TRACE | 默认 |
设置终端日志级别
终端日志级别只影响控制台输出,不影响文件保存。
from LOG import log
# 设置终端只显示 INFO 及以上级别
log.set_console_level('INFO')
# 设置终端只显示 WARNING 及以上级别
log.set_console_level('WARNING')
# 设置终端只显示 ERROR 及以上级别
log.set_console_level('ERROR')
# 获取当前终端日志级别
print(log.get_console_level_name()) # 输出: INFO
设置文件日志级别
文件日志级别控制哪些日志会被保存到文件中。
from LOG import log
# 设置文件只保存 INFO 及以上级别
log.set_file_level('INFO')
# 设置文件只保存 WARNING 及以上级别
log.set_file_level('WARNING')
# 设置文件只保存 ERROR 及以上级别
log.set_file_level('ERROR')
# 获取当前文件日志级别
print(log.get_file_level_name()) # 输出: INFO
日志级别优先级(从低到高)
CRITICAL = 15
ERROR = 14
WARNING = 13
NOTICE = 12
INFO = 11
DEBUG = 10
TRACE = 9
NOTSET = 0
设置某个级别后,只会显示该级别及更高级别的日志。
特性
- 控制台彩色输出
- 日志文件按日期自动分割
- 支持多种日志级别
- 自动创建日志目录
- 支持独立设置终端和文件日志级别
依赖
- logbook >= 1.5.0
License
MIT
Metadata
Release files for liwancai-PyLog 1.0.3
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 |
|---|---|---|---|---|
| liwancai_pylog-1.0.3.tar.gz | 4.6 kB | Without provenance | Details for liwancai_pylog-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| liwancai_pylog-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for liwancai_pylog-1.0.3-py3-none-any.whl |
Total release size: 9.3 kB
Release files / liwancai_pylog-1.0.3.tar.gz
| Download URL | liwancai_pylog-1.0.3.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30e65ea4125d74d6cc27a401f777ddd212c6eb752bbcaf7c32a105b79b177787
|
|
BLAKE2b-256 checksum How to use checksums |
b033679898a40f49c4d326a26d1d461d79a166b755f315ee581686970984f1e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / liwancai_pylog-1.0.3-py3-none-any.whl
| Download URL | liwancai_pylog-1.0.3-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a75fdfdc0ded50eaf2686e13b2e419584a08879cbd99f96e7d36f04494d7eba4
|
|
BLAKE2b-256 checksum How to use checksums |
7133fe7059578f70c8d9290b58c42fc5d550c9000791229117bdef4d51edf970
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for liwancai-PyLog 1.0.3
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.