default_builder

Function 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)
4fn main() {
5    let mut clog = colog::default_builder();
6    clog.filter(None, log::LevelFilter::Warn);
7    clog.init();
8    error!("error message");
9    error!("error with fmt: {}", 42);
10    warn!("warn message");
11
12    /*
13     * NOTE:
14     *
15     * The following log lines will not be printed, because the filter
16     * is set to LevelFilter::Warn
17     */
18    info!("info message");
19    debug!("debug message");
20    trace!("trace message");
21}