init_logging

Function init_logging 

Source
pub fn init_logging(
    component_name: &str,
    enable_file_logging: bool,
) -> Result<()>
Expand description

Initialize fancy logging for EDB components

This function sets up:

  • Colorful, structured console logging with timestamps
  • File logging to a temporary directory with daily rotation
  • Environment variable support for log levels (RUST_LOG)
  • Default INFO level if no RUST_LOG is set
  • Beautiful formatting with component names and spans

§Arguments

  • component_name - Name of the component (e.g., “edb”, “edb-rpc-proxy”)
  • enable_file_logging - Whether to enable file logging (default: true)

§Returns

  • Result<()> - Success or error from logging initialization

§Examples

use edb_common::logging;

#[tokio::main]
async fn main() -> eyre::Result<()> {
    // Initialize logging for the main EDB binary
    logging::init_logging("edb", true)?;
     
    tracing::info!("Application started");
    Ok(())
}