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
Metadata
Release files for logtube 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| logtube-1.0.1.tar.gz | 9.0 kB | Without provenance | Details for logtube-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| logtube-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for logtube-1.0.1-py3-none-any.whl |
Total release size: 19.4 kB
Release files / logtube-1.0.1.tar.gz
| Download URL | logtube-1.0.1.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
637ab76e290c5147fa3b5a32c39713eb65651c0540865d5b599068230b9ac880
|
|
BLAKE2b-256 checksum How to use checksums |
e76f807937843c7b38bb7e41fc9c47557df54a524a1fb3442421fe51e07ad17a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / logtube-1.0.1-py3-none-any.whl
| Download URL | logtube-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01da644159acfe5704a8b9ff48f1e7f9254176e754f43d816dde14afb5431cf5
|
|
BLAKE2b-256 checksum How to use checksums |
a61816da1959c79aa8b62739a7e6818b7ca900b1f47348571e3b9194217702b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for logtube 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.