]>
git.proxmox.com Git - rustc.git/blob - vendor/env_logger/examples/default.rs
4 Before running this example, try setting the `MY_LOG_LEVEL` environment variable to `info`:
7 $ export MY_LOG_LEVEL='info'
10 Also try setting the `MY_LOG_STYLE` environment variable to `never` to disable colors
11 or `auto` to enable them:
14 $ export MY_LOG_STYLE=never
24 // The `Env` lets us tweak what the environment
25 // variables to read are and what the default
26 // value is if they're missing
27 let env
= Env
::default()
28 .filter_or("MY_LOG_LEVEL", "trace")
29 .write_style_or("MY_LOG_STYLE", "always");
31 env_logger
::init_from_env(env
);
33 trace
!("some trace log");
34 debug
!("some debug log");
35 info
!("some information log");
36 warn
!("some warning log");
37 error
!("some error log");