init_logger

Function init_logger 

Source
pub fn init_logger<P: AsRef<Path>>(file_path: Option<P>) -> Result<(), LogError>
Expand description

Initialize a logger with default configuration.

This automatically reads from environment variables:

  • RUST_LOG for module-level filtering
  • LOG_LEVEL for numeric log level (0-5)

If neither is set, defaults to Info level with standard settings.

§Arguments

  • file_path - Optional path to a log file. If None, logs will only go to stdout.

§Returns

Ok(()) if initialization succeeded, or an error if it failed.

§Example

use fstdout_logger::init_logger;
use log::info;

init_logger(Some("app.log")).expect("Failed to initialize logger");
info!("Logger initialized with environment variable support");