1 /*!
2 Disabling parts of the default format.
3 
4 Before running this example, try setting the `MY_LOG_LEVEL` environment variable to `info`:
5 
6 ```no_run,shell
7 $ export MY_LOG_LEVEL='info'
8 ```
9 
10 Also try setting the `MY_LOG_STYLE` environment variable to `never` to disable colors
11 or `auto` to enable them:
12 
13 ```no_run,shell
14 $ export MY_LOG_STYLE=never
15 ```
16 
17 If you want to control the logging output completely, see the `custom_logger` example.
18 */
19 
20 use log::info;
21 
22 use env_logger::{Builder, Env};
23 
init_logger()24 fn init_logger() {
25     let env = Env::default()
26         .filter("MY_LOG_LEVEL")
27         .write_style("MY_LOG_STYLE");
28 
29     Builder::from_env(env)
30         .format_level(false)
31         .format_timestamp_nanos()
32         .init();
33 }
34 
main()35 fn main() {
36     init_logger();
37 
38     info!("a log from `MyLogger`");
39 }
40