Skip to main content

对logging进行二次封装, 操作更简单

Project description

对logging进行二次封装, 操作更简单

实例代码

from zlogger import logger

log = logger('test')
log.info('测试')

输出到文件

from zlogger import logger

log = logger('test', write_file=True)
log.info('测试')

指定输出文件的路径

from zlogger import logger

log = logger('test', write_file=True, file_dir='./')
log.info('测试')

单例

可能有多个模块会操作日志模块, 但是你希望只用一个日志对象来避免一个进程产生多个日志文件

from zlogger import logger_singleton

log = logger_singleton('test')
log.info('测试')

参数说明

参数名 数据类型 描述 默认值
name str 日志名
write_stream bool 是否输出日志到流(终端) True
write_file bool 是否输出日志到文件 False
file_dir str 日志文件的目录 .
level zlogger.LoggerLevel 日志等级 LoggerLevel.debug
interval int 间隔多少天重新创建一个日志文件 1
backup_count int 保留历史日志文件数量 2
append_pid bool 是否在日志文件名后附加进程号 False
log_format string 日志格式

本项目仅供所有人学习交流使用, 禁止用于商业用途

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Built Distribution

zlogger-0.1.3-py3-none-any.whl (3.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page