Skip to main content

A logger with standardized format for JF.

Project description

logo.png

jiushu-logger【九书】

简介

JF 专用格式化 logger。

听说有个人叫【九哥】,那我这个项目叫【九叔】很合理吧。(谐音梗扣钱!)

使用方法

引入包内所有内容:

from jiushu_logger import *

使用包内的 Logger 类写日志,该类中包含 bizreqcallcronmiddlewaremq 等六种日志格式。 同时每种日志格式都有对应属于自己的 extra 参数配置。

使用方法如下:

(注意:req 日志是专用于 flask 和 starlette 插件包的,不供开发者自行使用。)

from jiushu_logger import *

# 所有类型的日志均有 trace_id 和 duration 两项,但 trace_id 和 duration 均为非必需,duration 以秒为单位
Logger.biz.info('一个biz日志', extra=BizLogExtra(trace_id='xxx', duration=123.456))

# call 日志分为 INTERN 、 EXTERN 两种
Logger.call.warning('call警告', extra=CallLogExtra(type=CallType.EXTERN, params={'input': 'value1'},
                                                   resp={'output': 'value2'}))
Logger.call.warning('call警告', extra=CallLogExtra(type=CallType.EXTERN, params={'input': 'value1'},
                                                   resp={'output': 'value2'}))

# cron 日志适用于 xxl-job
Logger.cron.error('cron错误', extra=CronLogExtra(job_group='group', job_code='code'))

# middleware 日志分为 MYSQL 、 MONGO 、 REDIS 、 ES
Logger.middleware.debug('middleware调试',
                        extra=MiddlewareLogExtra(type=MiddlewareType.REDIS, host='x.x.x.x'))

# mq 日志分为 mq 、 mqtt 、 kafka , handle 分为 send 、 listen
Logger.middleware.info('', extra=MqLogExtra(type=MqType.KAFKA, handle_type=MqHandleType.LISTEN))
Logger.middleware.info('', extra=MqLogExtra(type=MqType.MQ, handle_type=MqHandleType.SEND))

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

jiushu_logger-1.0.5.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

jiushu_logger-1.0.5-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file jiushu_logger-1.0.5.tar.gz.

File metadata

  • Download URL: jiushu_logger-1.0.5.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for jiushu_logger-1.0.5.tar.gz
Algorithm Hash digest
SHA256 b4c1d7aa4ea93851536fbd7a3559178af66d35072680fae3ee96c397c231f9dc
MD5 5458830a2464411c5f42eb7ce6b31824
BLAKE2b-256 315775e934645ccc7ca729dcdc2af385504de13bc1d052e8e6bd235a9209191d

See more details on using hashes here.

File details

Details for the file jiushu_logger-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for jiushu_logger-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 46c63021ccf5da9c0a463ffc5deb6a074d8652f384690d40a67b3037d15038fc
MD5 c5e0b90fa6c69c3890d383e274c11774
BLAKE2b-256 2c8a4fb43b177933ffd66ff38b9e2e285f74941a698527d215e90cc7642bb60b

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