Changing the RUST_LOG variable to your own

If you release your own product, you may need to change the name of the RUST_LOG and the RUST_LOG_STYLE variable to your own. New releases of the env_logger contain the init_from_env special function to fix this. This expects one argument—an instance of the Env object. Take a look at the following code:

let env = env_logger::Env::new()
.filter("OWN_LOG_VAR")
.write_style("OWN_LOG_STYLE_VAR");
env_logger::init_from_env(env);

It creates an Env instance and sets the OWN_LOG_VAR variable to configure logging and the OWN_LOG_STYLE_VAR variable to control the style of the logs. When the env object is created, we will use it as an argument for the init_from_env function call of the env_logger crate.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.163.197