Module env_logger::fmt

source ·
Expand description

Formatting for log records.

This module contains a Formatter that can be used to format log records into without needing temporary allocations. Usually you won’t need to worry about the contents of this module and can use the Formatter like an ordinary Write.

Formatting log records

The format used to print log records can be customised using the Builder::format method. Custom formats can apply different color and weight to printed values using Style builders.

use std::io::Write;

let mut builder = env_logger::Builder::new();

builder.format(|buf, record| {
    writeln!(buf, "{}: {}",
        record.level(),
        record.args())
});

Modules

Structs

Enums

  • The set of available colors for the terminal foreground/background.
  • Log target, either stdout, stderr or a custom pipe.
  • Formatting precision of timestamps.
  • Whether or not to print styles to the target.

Type Aliases