Skip to main content

CheeseLog

介绍

一款完全动态的日志系统,它有以下特点:

  1. 多种的消息等级,可自定义添加新的等级。在打印与日志写入可以使用权重、指定消息或指定模块内的消息进行过滤,实现个性化的消息输出。

  2. 支持控制台样式打印,有完善的样式体系可以直接使用,自定义的消息模版可以实现个性化的消息输出,在未有打印环境的情况下停止打印节省资源。

  3. 支持日志文件记录,支持动态修改输出文件,可自由开启关闭。

  4. 可以输出自定义格式的进度条,这对于一些下载或加载的控制台显示非常有帮助。

目前仍处于开发阶段,各种功能并不保证以后的支持。

示例

带有日志文件输出的简易应用

from CheeseLog import CheeseLogger, Message

logger = CheeseLogger(file_path = 'logs/%Y-%m-%d.log')

logger.debug('This is a debug message.')
logger.info('This is an info message.')
logger.warning('This is a warning message.')
logger.danger('This is a danger message.')
logger.error('This is an error message.')

logger.add_message(Message('CUSTOM', 30, message_template_styled = '(<blue>%k</blue>) <black>%t</black> > %c'))
logger.print('CUSTOM', 'This is a custom message.')

简单的消息过滤

from CheeseLog import CheeseLogger, Message

logger = CheeseLogger()
logger.set_filter({
    'weight': 20,
    'message_keys': [ 'FILTERED' ]
})

low_weight_message = Message('LOW_WEIGHT', 10)
logger.add_message(low_weight_message)
high_weight_message = Message('HIGH_WEIGHT', 50)
logger.add_message(high_weight_message)
filtered_message = Message('FILTERED', 100)
logger.add_message(filtered_message)

logger.print('LOW_WEIGHT', 'This is a low weight message.', message_key = ) # 不会输出
logger.print('HIGH_WEIGHT', 'This is a high weight message.')
logger.print('FILTERED', 'This is a filtered message.') # 不会输出

如何使用进度条实现一个loading效果

import time, random

from CheeseLog import CheeseLogger, Message, ProgressBar

logger = CheeseLogger(file_path = 'logs/%Y-%m-%d.log')

loadingMessage = Message('LOADING')
logger.add_message(loadingMessage)
loadedMessage = Message('LOADED', 20, message_template_styled = '(<green>%k</green>) <black>%t</black> > %c')
logger.add_message(loadedMessage)

progress_bar = ProgressBar()
i = 0
while i < 100:
    bar, bar_styled = progress_bar(i / 100)
    logger.print('LOADING', bar, bar_styled, refresh = i != 0)
    time.sleep(random.uniform(0.05, 0.15))
    i += random.uniform(0.5, 1)
logger.print('LOADED', 'Loading complete!', refresh = True)

更多...

1. Style

2. Message

3. Logger

4. Progress Bar

Metadata

Release files for CheeseLog 2.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CheeseLog 2.1.6
File Size Uploaded Provenance Actions
cheeselog-2.1.6.tar.gz 7.3 kB Without provenance Details for cheeselog-2.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for CheeseLog 2.1.6
File Interpreter ABI Platform Actions
cheeselog-2.1.6-py2.py3-none-any.whl Python 2, Python 3 none any Details for cheeselog-2.1.6-py2.py3-none-any.whl

Total release size: 16.5 kB

Release files / cheeselog-2.1.6.tar.gz

Download URL cheeselog-2.1.6.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
08be7151ba21ce1086f5d9683c6c474649652e54a4955010d4eba24e07be3796
BLAKE2b-256 checksum
How to use checksums
e55049b0056374ee7407a89d29ed4bf162e4db497fc3a8d4dc130efacb82d65b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / cheeselog-2.1.6-py2.py3-none-any.whl

Download URL cheeselog-2.1.6-py2.py3-none-any.whl
Size 9.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fd8778e20ae056f6bb0e1a5f19c92e3a3f4a5d5b8787effd8a4d607496388dcd
BLAKE2b-256 checksum
How to use checksums
c04a3b1c9ef8bd427b795f95f34a711427f39a0010d9754f63e9b7d97858f1ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for CheeseLog 2.1.6

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.

Release history Release notifications | RSS feed

This release

2.1.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page