Metadata-Version: 2.4
Name: openinfra-logger
Version: 0.1.0
Summary: 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.
Home-page: https://github.com/jonathascordeiro20/openinfra-logger
Author: Jonathas
Author-email: Jonathas Cordeiro <jonathas.cordeiro2023@gmail.com>
License: MIT
Project-URL: Homepage, https://openinfralogger.fun
Project-URL: Repository, https://github.com/jonathascordeiro20/openinfra-logger
Project-URL: Documentation, https://github.com/jonathascordeiro20/openinfra-logger#readme
Project-URL: Changelog, https://github.com/jonathascordeiro20/openinfra-logger/blob/main/CHANGELOG.md
Project-URL: Bug Tracker, https://github.com/jonathascordeiro20/openinfra-logger/issues
Keywords: logging,logger,structured-logging,observability,telemetry,opentelemetry,datadog,elasticsearch,ecs,loki,zero-dependency,lgpd,gdpr,redaction
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Logging
Classifier: Typing :: Typed
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: opentelemetry
Requires-Dist: opentelemetry-api>=1.20; extra == "opentelemetry"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# OpenInfra Logger — Python

[![PyPI](https://img.shields.io/pypi/v/openinfra-logger?style=flat-square)](https://pypi.org/project/openinfra-logger/)
[![License](https://img.shields.io/pypi/l/openinfra-logger?style=flat-square)](https://github.com/jonathascordeiro20/openinfra-logger/blob/main/LICENSE)
[![Python Versions](https://img.shields.io/pypi/pyversions/openinfra-logger?style=flat-square)](https://pypi.org/project/openinfra-logger/)

**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

```bash
pip install openinfra-logger
```

## Quickstart

```python
from openinfra_logger import log, configure

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

## File + remote with batching

```python
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

```python
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(...)`.

```python
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:

```bash
pip install "openinfra-logger[opentelemetry]"
```

## Links

- **Source** — <https://github.com/jonathascordeiro20/openinfra-logger>
- **Issues** — <https://github.com/jonathascordeiro20/openinfra-logger/issues>
- **Changelog** — <https://github.com/jonathascordeiro20/openinfra-logger/blob/main/CHANGELOG.md>
- **Project site** — <https://openinfralogger.fun>

## License

MIT — see [LICENSE](https://github.com/jonathascordeiro20/openinfra-logger/blob/main/LICENSE).
