stellarmesh-logging
stellarmesh-logging 为 Python 3.11 及以上项目提供标准库 logging 的安全单行 JSON Formatter。主干准备 0.4.0(尚未发布,当前公共版本仍为 0.3.0),不包含远程 Client、HTTP token、后台线程、Kafka、spool、数据库表或日志级别策略,也没有运行时第三方依赖。
# 从本仓库根目录安装待发布源码
pip install ./sdk/python/logging
import logging
import sys
from stellarmesh_logging import JSONFormatter
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(
JSONFormatter(
static_fields={
"service": "orders-api",
"environment": "production",
}
)
)
logger = logging.getLogger("orders")
logger.setLevel(logging.INFO)
logger.addHandler(handler)
logger.info(
"request completed",
extra={"request_id": "request-1", "duration_ms": 12.5},
)
每条记录包含 time、level、msg 和 logger。项目可以用 static_fields 声明稳定字段,并通过 LogRecord.extra 添加自己的顶层字段;基础保留字段不能被覆盖。Formatter 支持异常结构化、Unicode、内置容器和敏感字段规范化后的精确匹配;固定字段和嵌套容器共享属性预算。token_count、session_id 不因敏感词子串而被遮盖。复杂业务对象、自定义容器和 dataclass 需先显式转为字段。
Formatter 不拥有 StreamHandler 或文件描述符。输出到 stdout、stderr、文件或其他目标,日志等级和 Handler 生命周期都由项目使用 Python 标准库配置。推荐输出结构化 stdout,再由项目自己的 Vector 等 Collector完成有界持久缓冲、恢复重放和数据库投影。
0.2.0 是旧远程 Logging v2 客户端的最后版本。0.3.0 是有意的破坏性版本,删除了 Client、LogEvent、StellarmeshHandler、结构化审计门面和关闭入口;仍依赖旧 API 的项目必须先完成 Collector迁移,不能直接升级。事务性审计应写入业务数据库或 transactional outbox,不能把普通 stdout日志当作合规级不可丢失记录。
0.4.0 的支持类型、节点预算和故障责任有意收窄,升级前阅读Python 接入与迁移教程和字段清洗约定。项目自己的凭据名称可通过 extra_sensitive_keys 扩展。
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.4.0.tar.gz.
File metadata
- Download URL: stellarmesh_logging-0.4.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4be61b646948cbafd644255decf4fa7b0d24b3ac19dd7ead0d898f735b9401f
|
|
| MD5 |
0255153e1fb95c58bac3d258a6bb698b
|
|
| BLAKE2b-256 |
b3479c0e28833168cb50ffaf1074cab256fe83416080f040b36a185504cae4d7
|
Provenance
The following attestation bundles were made for stellarmesh_logging-0.4.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.4.0.tar.gz -
Subject digest:
c4be61b646948cbafd644255decf4fa7b0d24b3ac19dd7ead0d898f735b9401f - Sigstore transparency entry: 2725597067
- Sigstore integration time:
-
Permalink:
L1ndenbaum/stellarmesh-sdk@2494919ce5d84d2710267959ca1ebf8fc7577469 -
Branch / Tag:
refs/tags/sdk/python/logging/v0.4.0 - Owner: https://github.com/L1ndenbaum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@2494919ce5d84d2710267959ca1ebf8fc7577469 -
Trigger Event:
push
-
Statement type:
File details
Details for the file stellarmesh_logging-0.4.0-py3-none-any.whl.
File metadata
- Download URL: stellarmesh_logging-0.4.0-py3-none-any.whl
- Upload date:
- Size: 6.4 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 |
2ff2f99d43596dbb7ef447db75562b1c8c3d6f873303a7ddb37947fe398e9090
|
|
| MD5 |
886ccd40ae0d7c7dd2f402972ae3dbda
|
|
| BLAKE2b-256 |
515ea296570a874fab15ea164b55a8a1a7fa29343566a3134ebb173d0bfa00ec
|
Provenance
The following attestation bundles were made for stellarmesh_logging-0.4.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.4.0-py3-none-any.whl -
Subject digest:
2ff2f99d43596dbb7ef447db75562b1c8c3d6f873303a7ddb37947fe398e9090 - Sigstore transparency entry: 2725597571
- Sigstore integration time:
-
Permalink:
L1ndenbaum/stellarmesh-sdk@2494919ce5d84d2710267959ca1ebf8fc7577469 -
Branch / Tag:
refs/tags/sdk/python/logging/v0.4.0 - Owner: https://github.com/L1ndenbaum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@2494919ce5d84d2710267959ca1ebf8fc7577469 -
Trigger Event:
push
-
Statement type: