Skip to main content

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},
)

每条记录包含 timelevelmsglogger。项目可以用 static_fields 声明稳定字段,并通过 LogRecord.extra 添加自己的顶层字段;基础保留字段不能被覆盖。Formatter 支持异常结构化、Unicode、内置容器和敏感字段规范化后的精确匹配;固定字段和嵌套容器共享属性预算。token_countsession_id 不因敏感词子串而被遮盖。复杂业务对象、自定义容器和 dataclass 需先显式转为字段。

Formatter 不拥有 StreamHandler 或文件描述符。输出到 stdout、stderr、文件或其他目标,日志等级和 Handler 生命周期都由项目使用 Python 标准库配置。推荐输出结构化 stdout,再由项目自己的 Vector 等 Collector完成有界持久缓冲、恢复重放和数据库投影。

0.2.0 是旧远程 Logging v2 客户端的最后版本。0.3.0 是有意的破坏性版本,删除了 ClientLogEventStellarmeshHandler、结构化审计门面和关闭入口;仍依赖旧 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

stellarmesh_logging-0.4.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stellarmesh_logging-0.4.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

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

Hashes for stellarmesh_logging-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c4be61b646948cbafd644255decf4fa7b0d24b3ac19dd7ead0d898f735b9401f
MD5 0255153e1fb95c58bac3d258a6bb698b
BLAKE2b-256 b3479c0e28833168cb50ffaf1074cab256fe83416080f040b36a185504cae4d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for stellarmesh_logging-0.4.0.tar.gz:

Publisher: release-python.yml on L1ndenbaum/stellarmesh-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stellarmesh_logging-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stellarmesh_logging-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ff2f99d43596dbb7ef447db75562b1c8c3d6f873303a7ddb37947fe398e9090
MD5 886ccd40ae0d7c7dd2f402972ae3dbda
BLAKE2b-256 515ea296570a874fab15ea164b55a8a1a7fa29343566a3134ebb173d0bfa00ec

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page