Skip to main content

A logging library for Python

Project description

SparkleLogging日志库

描述

这是一个可以支持异步记录日志,发送到HTTP,websocket服务器,同时配置简单,它还实现了识别代码异步和同步的环境 以支持不同环境下的日志记录,当然了,理论上,这个日志如果2个模式都启用(websocket,http),那么会分别的往2个地方发送日志

示例用法

#from core import *
from SparkleLogging.utils.core 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,
    custom_fomatter=Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s',datefmt="%H:%M:%S")
)

logger.info('这是一个成功信息')
logger.debug('这是一个调试信息')
logger.critical('这是一个严重错误信息')
logger.error('这是一个错误信息')
logger.warning('这是一个警告信息')

参数介绍

  • log_name: 指定日志记录器的名称
  • out_to_console: 是否输出到控制台,默认true
  • web_log_mode:是否启用websocket日志输出模式,默认false
  • WSpost_url: 如果启用websocket模式,则传入post_url,否则不管,默认None
  • HTTPpost_url: 如果启用http模式,则传入post_url,否则不管,默认None
  • http_mode: 是否启用http日志输出模式,默认false
  • setConsoleLevel: 设置控制台日志输出级别,默认DEBUG
  • setFileLevel: 设置文件日志输出级别,默认INFO
  • setWebLevel: 设置websocket日志输出级别,默认INFO
  • setHttpLevel: 设置http日志输出级别,默认INFO
  • custom_fomatter: 自定义格式化函数,默认None

更新日志

2024/5/18 19:24

更新了不同的堆栈格式和方便使用的装饰器

2024/2/20 1:01

更新了自定义格式功能,修复了少量bug

2024/5/2 20:10

更新了可以自定义设置日志等级的功能

添加参数

  • custom_formatter: 自定义格式化函数,默认None
  • setConsoleLevel: 设置控制台日志输出级别,默认DEBUG
  • setFileLevel: 设置文件日志输出级别,默认INFO
  • setWebLevel: 设置websocket日志输出级别,默认INFO
  • setHttpLevel: 设置http日志输出级别,默认INFO
  • custom_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

修复了时间格式毫秒数占用导致格式不美观的问题

Project details


Download files

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

Source Distribution

SparkleLogging-1.0.9.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

SparkleLogging-1.0.9-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file SparkleLogging-1.0.9.tar.gz.

File metadata

  • Download URL: SparkleLogging-1.0.9.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for SparkleLogging-1.0.9.tar.gz
Algorithm Hash digest
SHA256 1e4faacfd3c4fb1a70fe5d5023a01bfcc2ebf4b4e846f1eceb71c83522bf56ff
MD5 33b78d44d5329a84303add50fd76b2e2
BLAKE2b-256 448a945cd589ad88fd81af1e95001fe71b21daf7e114126f0b777642290d14c2

See more details on using hashes here.

File details

Details for the file SparkleLogging-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for SparkleLogging-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 bbcf4d3ed16348bb568de56aaf83155baf6c15b3eece0896f070e268d9640b1a
MD5 0c76ef9580d746dec0c3e75f845086c2
BLAKE2b-256 f69313e88bb7618b9f3bfe1cfaf232898e81076a6df482fcf752956891932d9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page