Function colog::default_builder

source ·
pub fn default_builder() -> Builder
Expand description

Opinionated builder, with colog defaults.

This function returns a builder that:

  • Uses colog formatting
  • Presents messages at severity LevelFilter::Info and up
  • Optionally uses RUST_LOG environment settings
let mut builder = colog::default_builder();
/* further builder setup here.. */
builder.init();
log::info!("logging is ready");
Examples found in repository?
examples/levels.rs (line 5)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let mut clog = colog::default_builder();
    clog.filter(None, log::LevelFilter::Warn);
    clog.init();
    error!("error message");
    error!("error with fmt: {}", 42);
    warn!("warn message");

    /*
     * NOTE:
     *
     * The following log lines will not be printed, because the filter
     * is set to LevelFilter::Warn
     */
    info!("info message");
    debug!("debug message");
    trace!("trace message");
}