try_setup

Function try_setup 

Source
pub fn try_setup() -> Result<(), SetLoggerError>
Expand description

Set up the log crate global logger.

This function calls log::set_logger to set up a LogCrateProxy and all logs from log crate will be forwarded to logforth’s default logger.

This should be called early in the execution of a Rust program. Any log events that occur before initialization will be ignored.

This function will set the global maximum log level to Trace. To override this, call log::set_max_level after this function.

§Errors

Return an error if the log crate global logger has already been set.

§Examples

if let Err(err) = logforth_bridge_log::try_setup() {
    eprintln!("failed to setup log crate: {err}");
}