babylon.config.logging_config
Logging configuration for Babylon/Babylon.
Logging is the nervous system of the simulation. Every action must be traceable, every decision auditable.
This module provides: - setup_logging(): Single entry point for logging initialization - load_logging_config(): Load config from pyproject.toml - RotatingFileHandler for main and error-only logs - JSONFormatter for machine-parseable output - Console handler for human-readable output
Configuration Hierarchy (highest precedence first): 1. LOG_LEVEL environment variable (global override) 2. pyproject.toml [tool.babylon.logging] section 3. logging.yaml file (if exists) 4. Default hardcoded values
Functions
|
Create a file handler for a specific simulation run. |
Get the current logging configuration (for debugging/inspection). |
|
|
Load logging configuration from pyproject.toml. |
|
Initialize the logging system. |
Classes
|
Centralized logging configuration loaded from pyproject.toml. |
- class babylon.config.logging_config.LoggingConfig(default_level='INFO', console_level='INFO', file_level='DEBUG', modules=<factory>)[source]
Bases:
objectCentralized logging configuration loaded from pyproject.toml.
- default_level
Global default log level
- console_level
Log level for console output
- file_level
Log level for file output
- modules
Per-module log level overrides
- babylon.config.logging_config.load_logging_config(pyproject_path=None)[source]
Load logging configuration from pyproject.toml.
- Parameters:
pyproject_path (
Path|None) – Path to pyproject.toml. If None, searches for it.- Return type:
- Returns:
LoggingConfig with settings from pyproject.toml or defaults.
The configuration is loaded from [tool.babylon.logging] section.
- babylon.config.logging_config.setup_logging(config_path=None, default_level=None, pyproject_path=None)[source]
Initialize the logging system.
- Parameters:
- Return type:
Configuration is loaded in this order (highest precedence first): 1. LOG_LEVEL environment variable 2. default_level parameter 3. pyproject.toml [tool.babylon.logging] section 4. logging.yaml file (if config_path provided) 5. Default values
The logging system is deterministic - given the same inputs, it produces the same outputs. No probabilistic behavior.
Handler hierarchy: - Console: Human-readable, INFO level (or configured level) - Main file (RotatingFileHandler): JSON Lines, DEBUG level, 10MB rotation - Error file (RotatingFileHandler): JSON Lines, ERROR only, 5MB rotation
- babylon.config.logging_config.create_simulation_handler(simulation_id, seed=None)[source]
Create a file handler for a specific simulation run.
Creates a per-simulation log file for forensic analysis and replay.
- Parameters:
- Return type:
- Returns:
Configured RotatingFileHandler for the simulation log.