A logger with standardized format for JF.
Project description
jiushu-logger【九书】
简介
JF 专用格式化 logger。
听说有个人叫【九哥】,那我这个项目叫【九叔】很合理吧。(谐音梗扣钱!)
使用方法
引入包内所有内容:
from jiushu_logger import *
使用包内的 Logger
类写日志,该类中包含 biz
、 req
、 call
、 cron
、 middleware
、 mq
等六种日志格式。
同时每种日志格式都有对应属于自己的 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(cate=CallType.INTERN, call_params={'input': 'value1'},
call_resp={'output': 'value2'}))
Logger.call.warning('call警告', extra=CallLogExtra(cate=CallType.INTERN, call_params={'input': 'value1'},
call_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(cate=MiddlewareType.REDIS, host='x.x.x.x'))
# mq 日志分为 mq 、 mqtt 、 kafka , handle 分为 send 、 listen
Logger.middleware.info('', extra=MqLogExtra(cate=MqType.KAFKA, handle=MqHandleType.LISTEN))
Logger.middleware.info('', extra=MqLogExtra(cate=MqType.MQ, handle=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.2.tar.gz
(17.0 kB
view details)
Built Distribution
File details
Details for the file jiushu_logger-1.0.2.tar.gz
.
File metadata
- Download URL: jiushu_logger-1.0.2.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad668ca65a7f6c07d86db52d7d361b9b859e94a5c43475f0c0a2aedeecb45c8d |
|
MD5 | 70bebec5b9100bd652d8d62388a66e52 |
|
BLAKE2b-256 | 78b33d0ee8deae82e38e061cec5aa6fbdb93b453c0fd6b5a2b133f9f18c07b41 |
File details
Details for the file jiushu_logger-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: jiushu_logger-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee18a3af45bf558b6feafc4e6ea167cc0da4710e3da4733153e7e39c007937c2 |
|
MD5 | e473ff046f884cd2d9d1b784f96be364 |
|
BLAKE2b-256 | 7d453a398b971a3b7b85e1b150edbb9b8ed79176eb26abd6cb0207f889465618 |