Skip to main content

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

Project description

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(...)

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

gqylpy_log-1.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

gqylpy_log-1.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file gqylpy_log-1.2.tar.gz.

File metadata

  • Download URL: gqylpy_log-1.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for gqylpy_log-1.2.tar.gz
Algorithm Hash digest
SHA256 456a786521324d48333c14ac58f57a1306011d0e05ffff7c4273f3ddd11d2b20
MD5 53dc70b3976b527ff48c2e117cf68ee5
BLAKE2b-256 752663a0edea99733eeed49ae57f9d9e1612f10f189a27abb835b58a7c782653

See more details on using hashes here.

File details

Details for the file gqylpy_log-1.2-py3-none-any.whl.

File metadata

  • Download URL: gqylpy_log-1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for gqylpy_log-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 36104ff0a9fbb9cb39b3bffa6238e3bd9fb4eb36d9b7d050443e0c59646fee26
MD5 b2efa342301862a3a6bb371b37d1d8f2
BLAKE2b-256 9660edfbcbc34d961720fdf77c9134673afe39b12db310a665cf0c5ca4610742

See more details on using hashes here.

Supported by

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