Skip to main content

LOGO Release Python Versions License Downloads

gqylpy-log

二次封装 logging,更方便快捷的创建日志记录器。使用 gqylpy_log 模块可以快速创建 logging.Logger 实例并完成一系列的日志配置,使你的代码更简洁。

pip3 install gqylpy_log

使用内置的日志记录器

gqylpy_log 中内置了一个基于 logging.StreamHandler 的日志记录器,你可以直接调用它:

import gqylpy_log as glog

glog.debug(...)
glog.info(...)
glog.warning(...)
glog.error(...)
glog.critical(...)

它的默认配置如下:

level   = "NOTSET"
output  = "stream"
logfile = "/var/log/{default is your startup filename}.log"
datefmt = "%F %T"
logfmt  = "[%(asctime)s] [%(module)s.%(funcName)s.line%(lineno)d] [%(levelname)s] %(message)s"

当然可以修改它:

glog.level  = "INFO"

不过需要注意的是,你只有在第一次调用前修改内置的日志记录器配置才会生效,因为在你第一次调用时默认的日志记录器就已经被创建!

创建一个新的日志记录器
import gqylpy_log as glog

glog.__init__(
    "alpha",
    level  ="INFO",
    output ="stream,file",
    logfmt ="[%(asctime)s] [%(levelname)s] %(message)s",
    datefmt="%F %T",
    logfile="/var/log/alpha.log",
    gname  ="alpha"
)

glog.info(...)

或者你希望直接得到日志记录器实例,而不是始终通过 gqylpy_log 模块调用它:

log: logging.Logger = glog.__init__("beta", ...)
log.info(...)

Metadata

Release files for gqylpy-log 1.2

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

Source distribution (sdist)

Source distribution for gqylpy-log 1.2
File Size Uploaded
gqylpy_log-1.2.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gqylpy-log 1.2
File Interpreter ABI Platform
gqylpy_log-1.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / gqylpy_log-1.2.tar.gz

Download URL gqylpy_log-1.2.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
456a786521324d48333c14ac58f57a1306011d0e05ffff7c4273f3ddd11d2b20
BLAKE2b-256 checksum
How to use checksums
752663a0edea99733eeed49ae57f9d9e1612f10f189a27abb835b58a7c782653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / gqylpy_log-1.2-py3-none-any.whl

Download URL gqylpy_log-1.2-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36104ff0a9fbb9cb39b3bffa6238e3bd9fb4eb36d9b7d050443e0c59646fee26
BLAKE2b-256 checksum
How to use checksums
9660edfbcbc34d961720fdf77c9134673afe39b12db310a665cf0c5ca4610742
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

2.0.2

2 release files

2.0.1

2 release files

2.0

2 release files

This release

1.2 This release

2 release files

1.1

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

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