stellarmesh-logging
stellarmesh-logging 为 Python 3.11 及以上项目提供 Logging v2 严格模型、标准库 logging.Handler、结构化日志门面和有界异步批量 HTTP 客户端。v2 使用 kind=LOG|AUDIT 表示事件种类,使用 level=DEBUG|INFO|WARNING|ERROR 表示严重程度。
python -m pip install stellarmesh-logging==0.2.0
import logging
from stellarmesh_logging import Client, ClientConfig, StellarmeshHandler
client = Client(
ClientConfig(
base_url="http://logging-service:8091",
token="由业务配置层注入",
service="example-worker",
)
)
logger = logging.getLogger("example")
logger.addHandler(StellarmeshHandler(client))
logger.info("job started", extra={"job_id": "job-123"})
client.close(timeout=10.0)
标准库 StellarmeshHandler 始终生成 kind=LOG。审计事件必须通过结构化门面显式产生:
from stellarmesh_logging import Level, get_logger
audit_logger = get_logger("example.audit", client=client)
audit_logger.audit(
"role granted",
level=Level.INFO,
action="iam.role.grant",
outcome="success",
)
AUDIT 会在客户端整体启用时绕过 minimum_level,但仍可能因为队列已满、关闭超时或远程发送失败而丢弃。它不是合规级不可丢失或 WORM 审计存储。
客户端只在内存中排队日志,不提供本地持久 spool。日志调用成功只表示事件已经进入本地队列;收到 logging-service 的合法 202 后,才表示 Kafka 或服务端持久 spool 已经确认。网络结果不确定时可能产生重复事件,链路按 at-least-once 边界设计。
service 必须非空且没有首尾空白。token 只发送给 logging-service,metadata 会限制深度、数量和字符串长度,并对规范化后的敏感 key 脱敏。应用退出前应显式调用 close() 或 aclose(),并通过 drop_handler 观测队列满、校验失败、发送失败和关闭超时。
完整配置、标准 Handler、trace 传播、重试和关闭语义见项目中的 docs/sdk/python/README.md。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stellarmesh_logging-0.2.0.tar.gz.
File metadata
- Download URL: stellarmesh_logging-0.2.0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20a3678bfc076e750c281f14cdbb793054f5fefcfd75fe6f905824bc51dd13e7
|
|
| MD5 |
91c8202883f0cd1d7ed1c9de89048c4e
|
|
| BLAKE2b-256 |
c366b6a2efceaa4ae7540828e39f62db794fb7f711f987b5c6580910dc4f0d9e
|
Provenance
The following attestation bundles were made for stellarmesh_logging-0.2.0.tar.gz:
Publisher:
release-python.yml on L1ndenbaum/stellarmesh-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stellarmesh_logging-0.2.0.tar.gz -
Subject digest:
20a3678bfc076e750c281f14cdbb793054f5fefcfd75fe6f905824bc51dd13e7 - Sigstore transparency entry: 2649268275
- Sigstore integration time:
-
Permalink:
L1ndenbaum/stellarmesh-sdk@e61313e864f8e314de36073321e24e849210e7df -
Branch / Tag:
refs/tags/sdk/python/logging/v0.2.0 - Owner: https://github.com/L1ndenbaum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@e61313e864f8e314de36073321e24e849210e7df -
Trigger Event:
push
-
Statement type:
File details
Details for the file stellarmesh_logging-0.2.0-py3-none-any.whl.
File metadata
- Download URL: stellarmesh_logging-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1f8389d98a70cc23075c544222c12da97c8968486d0d0727b527314742d2cfe
|
|
| MD5 |
d4f30d1422b1d927d2cf0eed82bdb890
|
|
| BLAKE2b-256 |
d7e3f172216498b321dd0375c366c2ba0721928898d5015bff34893473d6f32d
|
Provenance
The following attestation bundles were made for stellarmesh_logging-0.2.0-py3-none-any.whl:
Publisher:
release-python.yml on L1ndenbaum/stellarmesh-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stellarmesh_logging-0.2.0-py3-none-any.whl -
Subject digest:
a1f8389d98a70cc23075c544222c12da97c8968486d0d0727b527314742d2cfe - Sigstore transparency entry: 2649268425
- Sigstore integration time:
-
Permalink:
L1ndenbaum/stellarmesh-sdk@e61313e864f8e314de36073321e24e849210e7df -
Branch / Tag:
refs/tags/sdk/python/logging/v0.2.0 - Owner: https://github.com/L1ndenbaum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@e61313e864f8e314de36073321e24e849210e7df -
Trigger Event:
push
-
Statement type: