Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Eventual Inc Daft Logging Configuration

From Leeroopedia


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:

  1. Sets the Python `logging` module level and format.
  2. Synchronizes the Rust `log` crate level via a bridge function (`refresh_logger`), which reads the Python logger state or the `DAFT_LOG` environment variable.
  3. 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:

  1. The Python logger level is the authoritative source (or overridden by an environment variable).
  2. The Rust log filter is derived from the Python level via `pyo3-log`'s `ResetHandle`.
  3. Prefix-based filtering allows selective verbosity without modifying individual module loggers.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment