Skip to main content

init_logging

Function init_logging 

Source
pub fn init_logging(config: &LogConfig)
Expand description

Initialize logging for the rust-ai ecosystem.

This function should be called once at application startup. It configures the global tracing subscriber based on the provided configuration.

§Arguments

  • config - Logging configuration

§Why Single Initialization

The tracing subscriber is global. Multiple initialization attempts would either panic or silently fail. This function uses Once to ensure safe idempotent calls.

§Environment Override

The RUST_LOG environment variable always takes precedence over the config’s default level. This allows runtime tuning without recompilation.

§Example

use rust_ai_core::{init_logging, LogConfig};

// Initialize with defaults
init_logging(&LogConfig::default());

// Or with explicit config
init_logging(&LogConfig::development());