Logtube Python SDK
Project description
logtube-python
logtube python sdk
设置
from src import logtube
logtube.setup({
# 项目名,唯一标识一个项目
"project": "eshop-id-service",
# 环境名,用以区分不同环境
"env": "dev",
# 命令行输出
"console": {
"topics": ["*", "-debug"] # 输出除了 debug 之外的所有主题
},
# 文件输出
"file": {
"topics": ["*", "-debug"], # 输出除了 debug 之外的所有主题
"dir": "logs", # 设置日志输出的根目录
"subdirs": { # 设置子目录
"xlog": ["*", "-debug"] # 非调试日志输出到 `xlog` 子目录,其他日志进入 `others` 子目录
}
}
})
一般日志输出
第一个参数为关键字,可以用于为日志输出打一个关键字,鉴于日志量过大,info 日志必须通过关键字检索
from src import logtube
logtube.debug("关键字", "文本")
logtube.info("关键字", "文本")
logtube.warn("关键字", "文本")
logtube.error("关键字", "文本")
logtube.fatal("关键字", "文本")
Job 工具
针对任务类型的日志,Logtube 提供了工具类
from src import logtube
j = logtube.job()
j.set_job_name("sleep-job-1m") # 设置任务名,用于区分一类任务
j.set_job_id("xxxxx-xxxxx-xxxxx-xxxxx") # 设置任务编号,用于追踪同一个任务
j.add_keyword("hello") # 可以增加关键字
j.add_extra("key", "val") # 可以增加附属键值对
j.mark_start() # 标记任务开始
# ... 此处为耗时很久的业务代码
j.mark_end(True, "任务成功") # 标记任务结束和任务结果,True 为成功,可以额外添加任意纯文本
# committer.mark_end(False, "任务失败,因为 xxx.xxxx")
许可证
Guo Y.K., MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
logtube-1.0.0.tar.gz
(9.1 kB
view details)
Built Distribution
logtube-1.0.0-py3-none-any.whl
(10.4 kB
view details)
File details
Details for the file logtube-1.0.0.tar.gz
.
File metadata
- Download URL: logtube-1.0.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb2ab7877fa96c4b620eefe18717f70d5d962b5ce52e5d25bacf9abab00c93e3 |
|
MD5 | 229ce95ba26a5d166bedf7b0088520f1 |
|
BLAKE2b-256 | 0970e68109400b73039355f0030c955ceb98760bdf7196823c9666a7972b696b |
File details
Details for the file logtube-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: logtube-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dce825670c0906b14a52cf03f3439e51639a2bdc4dba47e256720f45b9398943 |
|
MD5 | d542d8ebebc0a24bc956a8295d08ffc2 |
|
BLAKE2b-256 | ea0cb744e22a237e5f3fd8d8ad509df8031414bf5cb1da87d5a79b7909cb2287 |