Skip to main content

用于测试框架的日志封装

Project description

hogwarts-logger

what

hogwarts-logger,一个专门方便pycharm查看的log库。

why

为了方便霍格沃兹学社的测试开发教学,开发了一个方便打印日志的库

where 特点

  • 可以打印pycharm直接点击到源文件位置的路径提示
  • 可以打印上下log之间的耗时
  • 可以打印函数调用链 function call trace

how

项目级别logger

默认使用包名作为日志名字,适合项目中统一使用。

from hogwarts_logger import Logger

logger = Logger.get_instance()

实例级别logger

允许创建多种Logger

from hogwarts_logger import Logger

logger1 = Logger()
logger2 = Logger()

便捷使用

from hogwarts_logger import *

trace('trace message')
debug('debug message')
info('info message')

日志级别

from hogwarts_logger import Logger

logger = Logger()
logger.set_level(logger.trace_level)
logger.trace('trace')
logger.log('trace')
logger.debug('debug')
logger.info('info')
logger.warn('warn')

default 默认级别

info
warn

info级别

test_path_log.py:199:test_info_level 2025-03-23 03:47:05,971 I info
test_path_log.py:200:test_info_level 2025-03-23 03:47:05,972 W warn

debug级别

test_path_log.py:188:test_debug_level:0.00  2025-03-23 03:47:05,968 D debug
test_path_log.py:189:test_debug_level:0.00  2025-03-23 03:47:05,969 I info
test_path_log.py:190:test_debug_level:0.00  2025-03-23 03:47:05,969 W warn

trace级别

test_path_log.py:177:pytest_pyfunc_call:test_trace_level:0.00 2025-03-23 03:47:05,965 L trace
test_path_log.py:178:pytest_pyfunc_call:test_trace_level:0.00 2025-03-23 03:47:05,966 D debug
test_path_log.py:179:pytest_pyfunc_call:test_trace_level:0.00 2025-03-23 03:47:05,966 I info
test_path_log.py:180:pytest_pyfunc_call:test_trace_level:0.00 2025-03-23 03:47:05,967 W warn

who

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

ceshiren_logger-1.0.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ceshiren_logger-1.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file ceshiren_logger-1.0.2.tar.gz.

File metadata

  • Download URL: ceshiren_logger-1.0.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ceshiren_logger-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5d96ae42c7f1f40af7ccfbbbd0c5c01baf2fa43bc30314d0c4534ce52d5cc87c
MD5 42b0e70f8d75c7dfdf31e6abec122d23
BLAKE2b-256 07470aa4544d70877be87a4233195179808ecc77e6692a3f374b2f2a18479142

See more details on using hashes here.

Provenance

The following attestation bundles were made for ceshiren_logger-1.0.2.tar.gz:

Publisher: python-publish.yml on ceshiren/hogwarts-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ceshiren_logger-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ceshiren_logger-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf3b385b68577d272ba247219d4c4dd9837e68118d4d92e945ac83b2f5e0d581
MD5 a17f453a735e7b81263c99f607a41473
BLAKE2b-256 2ca9fa2d726e068f75f0731286a48de348a8b6bccb6481252f1dab420adc78ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for ceshiren_logger-1.0.2-py3-none-any.whl:

Publisher: python-publish.yml on ceshiren/hogwarts-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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