pyUnit-log 
日志处理模块集合
安装
pip install pyunit-log
亮点
快速简单的函数日志模块,只需要在函数头上写一个装饰器即可,一行代码解决日志问题。
@log(log_file='./logs')
日志装饰器
from pyunit_log import log
if __name__ == '__main__':
#config_file是日志模板地址,不写默认加载
@log(log_file='./logs',config_file=None)
def division():
pass
加载默认日志配置
from pyunit_log import Log
import logging
if __name__ == '__main__':
Log()
logging.info('默认加载到root下')
info = logging.getLogger('info')
info.info('日志文件写道info.log文件下')
error = logging.getLogger('error')
error.error('日志文件写道error.log文件下')
修改日志配置文件
from pyunit_log import Log
import logging
if __name__ == '__main__':
Log(config_file = '',log_file = '')
# log_file 修改保存日志文件夹地址
# config_file 修改配置文件地址
info = logging.getLogger('info')
info.info('日志文件写道info.log文件下')
error = logging.getLogger('error')
error.error('日志文件写道error.log文件下')
修改配置文件格式
[loggers]
keys = root,info,error
[handlers]
keys = console,info,error
[formatters]
keys = simpleFormatter
[formatter_simpleFormatter]
format = %(asctime)s - %(module)s - %(thread)d - %(levelname)s : %(message)s
datefmt = %Y-%m-%d %H:%M:%S
[logger_root]
level = INFO
handlers = info,console
[handler_console]
class = StreamHandler
level = INFO
formatter = simpleFormatter
args = (sys.stdout,)
[logger_info]
level = INFO
handlers = info
qualname = info
propagate = 0
[handler_info]
class = handlers.RotatingFileHandler
formatter = simpleFormatter
args = ('logs/info.log', 'a', 1048576, 30, 'UTF-8')
[logger_error]
level = ERROR
handlers = error
qualname = error
propagate = 0
[handler_error]
class = handlers.TimedRotatingFileHandler
formatter = simpleFormatter
args = ('logs/error.log', 'D', 1, 30, 'UTF-8')
日志大小说明
默认:info日志是1M(1048576)分割
error日志是每天分割
Metadata
Release files for pyunit-log 2020.9.2
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 |
|---|---|---|---|---|
| pyunit_log-2020.9.2.tar.gz | 4.3 kB | Without provenance | Details for pyunit_log-2020.9.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyunit_log-2020.9.2-py3-none-any.whl | Python 3 | none | any | Details for pyunit_log-2020.9.2-py3-none-any.whl |
Total release size: 9.3 kB
Release files / pyunit_log-2020.9.2.tar.gz
| Download URL | pyunit_log-2020.9.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4c03cb8b3f733ed75e21688767ebbbc1e2a4e2973547ad4b81d3fbf7d171c1f
|
|
BLAKE2b-256 checksum How to use checksums |
3070f3329f855f2dfddc0da9c602475585c035a75f1f049fd47d0ee5bcad8624
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Release files / pyunit_log-2020.9.2-py3-none-any.whl
| Download URL | pyunit_log-2020.9.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
449d588b22cbda31c6112494cdc3b179014e27edcf95df2ce295d6617a4a4837
|
|
BLAKE2b-256 checksum How to use checksums |
7b13ef2aa81ecbbd3719be5dd90c8654e28f5fd35b37d9ba80aee67c6209c0e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Security for pyunit-log 2020.9.2
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.