
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
python 颜色缤纷的日志
封装了 colorlog 使其更易用,效果如图:
其特点为:
requests
chardet.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'
]
)
详见 单元测试说明
支付宝 | 微信 |
---|---|
![]() | ![]() |
FAQs
python color log
We found that py-color-log demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.