Skip to main content

stellarmesh-logging

stellarmesh-logging 为 Python 3.11 及以上项目提供标准库 logging 的安全单行 JSON Formatter。0.3.0 不包含远程 Client、HTTP token、后台线程、Kafka、spool、数据库表或日志级别策略,也没有运行时第三方依赖。

pip install stellarmesh-logging==0.3.0
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、嵌套值、敏感字段规范化脱敏,以及消息、字符串、属性数量和嵌套深度限制。

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

0.2.0 是旧远程 Logging v2 客户端的最后版本。0.3.0 是有意的破坏性版本,删除了 ClientLogEventStellarmeshHandler、结构化审计门面和关闭入口;仍依赖旧 API 的项目必须先完成 Collector迁移,不能直接升级。事务性审计应写入业务数据库或 transactional outbox,不能把普通 stdout日志当作合规级不可丢失记录。

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.3.0.tar.gz (7.3 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.3.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file stellarmesh_logging-0.3.0.tar.gz.

File metadata

  • Download URL: stellarmesh_logging-0.3.0.tar.gz
  • Upload date:
  • Size: 7.3 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.3.0.tar.gz
Algorithm Hash digest
SHA256 40daaf64f3df799868c2fc0e04e175cf0cb712454f744e92b9393caacbd764ca
MD5 7281ab161ebed57b9e2c5370fc3ba924
BLAKE2b-256 db49fd4be7c1b23d3a0a40dab15cf6be1e69d811f86aba2c7c1a65d4aa1231aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for stellarmesh_logging-0.3.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.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stellarmesh_logging-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 703a9744f149a24bda6e55532e13328ed3dee1ef066276ddba66742da1cb5ae0
MD5 65a877afeb0cf4fa3d576cbdf15a341f
BLAKE2b-256 58ceb73adb58d2b4ba7aa93ab7ae76e9d78280e4266dd65c5b648e9db0a222d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for stellarmesh_logging-0.3.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

0.4.0

2 files

This release

0.3.0 This release

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