custom_default_format/
custom_default_format.rs

1/*!
2Disabling parts of the default format.
3
4Before 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
10Also try setting the `MY_LOG_STYLE` environment variable to `never` to disable colors
11or `auto` to enable them:
12
13```no_run,shell
14$ export MY_LOG_STYLE=never
15```
16
17If you want to control the logging output completely, see the `custom_logger` example.
18*/
19
20use log::info;
21
22use env_logger::{Builder, Env};
23
24fn 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
35fn main() {
36    init_logger();
37
38    info!("a log from `MyLogger`");
39}