Skip to main content

Universal structured logging and observability for Node, Python, Go and Rust — built from the standard library only. Native batching, auto-redaction, OpenTelemetry-aware, with native Datadog and Elastic (ECS) formatters.

Project description

OpenInfra Logger — Python

PyPI License Python Versions

OpenInfra Logger is a zero-dependency, structured logging library — built from the Python standard library only — with native batching, auto-redaction, OpenTelemetry trace injection, and Datadog/Elastic formatters.

The same JSON shape is emitted by sibling implementations for Node.js, Go and Rust, making polyglot stacks observable with a single log format.

Install

pip install openinfra-logger

Quickstart

from openinfra_logger import log, configure

log("System initialized", "info")
log("Failed to parse payload", "error", {"request_id": "abc-123"})

File + remote with batching

from openinfra_logger import log, configure

configure(
    transports=["console", "file", "remote"],
    file_path="./production.log",
    remote_url="https://logs.my-infrastructure.com/ingest",
    default_metadata={"service": "payment-gateway", "env": "production"},
    batch_size=100,
    flush_interval_ms=2000,
)

log("Payment processed", "info", {"transaction_id": "abc-456"})

Datadog / Elastic formatters

configure(formatter="datadog")   # renames level → status, trace_id → dd.trace_id
# configure(formatter="elastic") # renames timestamp → @timestamp, level → log.level

Auto-redaction (LGPD / GDPR)

Sensitive keys (password, token, secret, api_key, credit_card) are recursively replaced with [REDACTED] before any transport sees the entry. Case-insensitive on key names. Override via redact_keys=[...] in configure(...).

log("Login", "info", {"user": "alice", "password": "p@ss"})
# → "...","user":"alice","password":"[REDACTED]"

OpenTelemetry tracing

If an OTel span is active in the current context, trace_id and span_id are picked up automatically. Install the optional extra to enable detection:

pip install "openinfra-logger[opentelemetry]"

Links

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openinfra_logger-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

openinfra_logger-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file openinfra_logger-0.1.0.tar.gz.

File metadata

  • Download URL: openinfra_logger-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openinfra_logger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 acde60488056399d560c38a4cd04f68bca92c6c3dbdc693ae810379d74eaea8a
MD5 1eafd7f2c88555ae02777e3e9dec37a6
BLAKE2b-256 9d98271bffdcb69f3fea39def430cae59c7bb8a3817bafad4fa1072ab589bc93

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinfra_logger-0.1.0.tar.gz:

Publisher: publish-pypi.yml on jonathascordeiro20/openinfra-logger

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

File details

Details for the file openinfra_logger-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openinfra_logger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97e9acfeb5ebbfefb3476e7cecc796a1ab68b2fe2b083453767d1ecbe1ebc409
MD5 f2a5f19315de401314e43c6e29388290
BLAKE2b-256 fbd1924a6b2ff4622a4db4fb40bf89be7f6ec55e6c92dd5b06f2192d8df73b76

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinfra_logger-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on jonathascordeiro20/openinfra-logger

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page