Skip to main content

init_logging

Function init_logging 

Source
pub fn init_logging(cfg: &LoggingConfig) -> Result<LoggingGuard, AppError>
Expand description

Initialize structured logging from a LoggingConfig with default masking.

  • LogFormat::Json → newline-delimited JSON (production)
  • LogFormat::Console → human-readable with colour (development)

Masking is enabled by default — sensitive fields are redacted before reaching the output sink. Use init_logging_with_options for full control over masking, sampling, and per-module levels.

The RUST_LOG env var takes precedence over cfg.level when set.

§Errors

Returns an error when the configured file output cannot be opened.