clementine_core::utils

Function initialize_logger

Source
pub fn initialize_logger(
    default_level: Option<LevelFilter>,
) -> Result<(), BridgeError>
Expand description

Initializes a [tracing] subscriber depending on the environment. [EnvFilter] is used with an optional default level. Sets up the color_eyre handler.

§Log Formats

  • json JSON is used when LOG_FORMAT=json
  • human Human-readable direct logs are used when LOG_FORMAT is not set to json.

§CI

In CI, logging is always in the human-readable format with output to the console. The INFO_LOG_FILE env var can be used to set an optional log file output. If not set, only console logging is used.

§Backtraces

Backtraces are enabled by default for tests. Error backtraces otherwise depend on the RUST_LIB_BACKTRACE env var. Please read color_eyre documentation for more details.

§Parameters

  • default_level: Default level ranges from 0 to 5. This is overwritten through the RUST_LOG env var.

§Returns

Returns Err in CI if the file logging cannot be initialized. Already initialized errors are ignored, so this function can be called multiple times safely.