Module 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())
});

Structs§

Formatter
A formatter to write logs into.
Style
A set of styles to apply to the terminal output.
StyledValue
A value that can be printed using the given styles.
Timestamp
An RFC3339 formatted timestamp.

Enums§

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