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.
Terminal styling is done through ANSI escape codes and will be adapted to the capabilities of the target stream. For example, you could use one of:
- anstyle is a minimal, runtime string styling API and is re-exported as
style - owo-colors is a feature rich runtime string styling API
- color-print for feature-rich compile-time styling API
See also
Formatter::default_level_style
use std::io::Write;
let mut builder = env_logger::Builder::new();
builder.format(|buf, record| {
writeln!(buf, "{}: {}",
record.level(),
record.args())
});Re-exports§
pub use anstyle as style;color
Structs§
Enums§
- Log target, either
stdout,stderror a custom pipe. - Formatting precision of timestamps.
- Whether or not to print styles to the target.