Principle:Eventual Inc Daft Logging Configuration
| Knowledge Sources | |
|---|---|
| Domains | Logging, Observability |
| Last Updated | 2026-02-08 14:00 GMT |
Overview
Pattern for providing unified log level configuration across Python and Rust runtimes in a hybrid language system.
Description
In a Python-Rust hybrid system, logging must be synchronized across both runtimes. Logging Configuration provides a single entry point that:
- Sets the Python `logging` module level and format.
- Synchronizes the Rust `log` crate level via a bridge function (`refresh_logger`), which reads the Python logger state or the `DAFT_LOG` environment variable.
- Supports namespace filtering to restrict output to specific module prefixes.
This ensures that both Python-level logs and Rust-level logs (forwarded via `pyo3-log`) appear at the same verbosity level.
Usage
Apply this principle in any hybrid Python-Rust project where both layers produce log output. Users should call the configuration function once at program startup.
Theoretical Basis
The synchronization follows a single source of truth model:
- The Python logger level is the authoritative source (or overridden by an environment variable).
- The Rust log filter is derived from the Python level via `pyo3-log`'s `ResetHandle`.
- Prefix-based filtering allows selective verbosity without modifying individual module loggers.