Skip to main content

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

stellarmesh_logging-0.2.0.tar.gz (20.9 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.2.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

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

Hashes for stellarmesh_logging-0.2.0.tar.gz
Algorithm Hash digest
SHA256 20a3678bfc076e750c281f14cdbb793054f5fefcfd75fe6f905824bc51dd13e7
MD5 91c8202883f0cd1d7ed1c9de89048c4e
BLAKE2b-256 c366b6a2efceaa4ae7540828e39f62db794fb7f711f987b5c6580910dc4f0d9e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for stellarmesh_logging-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1f8389d98a70cc23075c544222c12da97c8968486d0d0727b527314742d2cfe
MD5 d4f30d1422b1d927d2cf0eed82bdb890
BLAKE2b-256 d7e3f172216498b321dd0375c366c2ba0721928898d5015bff34893473d6f32d

See more details on using hashes here.

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

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

0.3.0

2 files

This release

0.2.0 This release

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