SparkleLogging日志库
描述
这是一个可以支持异步记录日志,发送到HTTP,websocket服务器,同时配置简单,它还实现了识别代码异步和同步的环境 以支持不同环境下的日志记录,当然了,理论上,这个日志如果2个模式都启用(websocket,http),那么会分别的往2个地方发送日志
示例用法
from SparkleLogging import LogManager
from logging import Formatter
logger = LogManager.GetLogger(
log_name='example',
out_to_console=True,
web_log_mode=True,
WSpost_url='ws://localhost:8765',
HTTPpost_url='http://localhost:8765',
http_mode = True,
out_to_file=True,
custom_fomatter=Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s',datefmt="%H:%M:%S")
)
logger.debug('这是一个调试信息')
logger.info('这是一个成功信息')
logger.warning('这是一个警告信息')
logger.error('这是一个错误信息')
logger.critical('这是一个严重错误信息')
参数介绍
log_name: 指定日志记录器的名称out_to_console: 是否输出到控制台,默认trueweb_log_mode:是否启用websocket日志输出模式,默认falseWSpost_url: 如果启用websocket模式,则传入post_url,否则不管,默认NoneHTTPpost_url: 如果启用http模式,则传入post_url,否则不管,默认Nonehttp_mode: 是否启用http日志输出模式,默认falsesetConsoleLevel: 设置控制台日志输出级别,默认DEBUGsetFileLevel: 设置文件日志输出级别,默认INFOsetWebLevel: 设置websocket日志输出级别,默认INFOsetHttpLevel: 设置http日志输出级别,默认INFOcustom_fomatter: 自定义格式化函数,默认Noneout_to_file: 设置是否输出到文件,默认为True
更新日志
2024/5/19 20:20
添加了out_to_file参数,改善了代码,现在可以用 from SparkleLogging import logger 来直接导入使用!
2024/5/18 19:24
更新了不同的堆栈格式和方便使用的装饰器
2024/2/20 1:01
更新了自定义格式功能,修复了少量bug
2024/5/2 20:10
更新了可以自定义设置日志等级的功能
添加参数
custom_formatter: 自定义格式化函数,默认NonesetConsoleLevel: 设置控制台日志输出级别,默认DEBUGsetFileLevel: 设置文件日志输出级别,默认INFOsetWebLevel: 设置websocket日志输出级别,默认INFOsetHttpLevel: 设置http日志输出级别,默认INFOcustom_fomatter: 自定义格式化函数,默认None
2024/5/3 1:05
更新了一个默认日志记录器
2024/5/3 1:17
修复了一个bug
2024/5/3 11:54
更改了core.py文件,让其导入可以直接使用
2024/5/4 11:09
修复了时间格式毫秒数占用导致格式不美观的问题
Metadata
Release files for SparkleLogging 1.1.0
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 |
|---|---|---|---|---|
| SparkleLogging-1.1.0.tar.gz | 7.4 kB | Without provenance | Details for SparkleLogging-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SparkleLogging-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for SparkleLogging-1.1.0-py3-none-any.whl |
Total release size: 16.4 kB
Release files / SparkleLogging-1.1.0.tar.gz
| Download URL | SparkleLogging-1.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4bd6c3b8441949109bbf0c080b5ddcb35ed8bc4b24f3ea646560f4363fe1299b
|
|
BLAKE2b-256 checksum How to use checksums |
cd47830b8c31312bfb85c861c1ba5568cafe55a1deddf911c90edd28a366bbdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / SparkleLogging-1.1.0-py3-none-any.whl
| Download URL | SparkleLogging-1.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c168067bae67d502fecde190c4f1b25dbd4a1c2829fcf4a449c90080639fd00
|
|
BLAKE2b-256 checksum How to use checksums |
519e8d6346601db5b55b244a5f8d8ab1e72ad75858e520f69c0754508583a9f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for SparkleLogging 1.1.0
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.