logo
pub struct Format<F = Full, T = SystemTime> { /* private fields */ }
Expand description

A pre-configured event formatter.

You will usually want to use this as the FormatEvent for a FmtSubscriber.

The default logging format, Full includes all fields in each event and its containing spans. The Compact logging format is intended to produce shorter log lines; it displays each event’s fields, along with fields from the current span context, but other information is abbreviated. The Pretty logging format is an extra-verbose, multi-line human-readable logging format intended for use in development.

Implementations

Use a less verbose output format.

See Compact.

Use an excessively pretty, human-readable output format.

See Pretty.

Note that this requires the “ansi” feature to be enabled.

Options

Format::with_ansi can be used to disable ANSI terminal escape codes (which enable formatting such as colors, bold, italic, etc) in event formatting. However, a field formatter must be manually provided to avoid ANSI in the formatting of parent spans, like so:

tracing_subscriber::fmt()
   .pretty()
   .with_ansi(false)
   .fmt_fields(format::PrettyFields::new().with_ansi(false))
   // ... other settings ...
   .init();

Use the given timer for log message timestamps.

See time module for the provided timer implementations.

Note that using the "time" feature flag enables the additional time formatters UtcTime and LocalTime, which use the time crate to provide more sophisticated timestamp formatting options.

Do not emit timestamps with log messages.

Enable ANSI terminal colors for formatted output.

Sets whether or not an event’s target is displayed.

Sets whether or not an event’s level is displayed.

Sets whether or not the thread ID of the current thread is displayed when formatting events

Sets whether or not the name of the current thread is displayed when formatting events

Sets whether or not an event’s source code file path is displayed.

Sets whether or not an event’s source code line number is displayed.

Sets whether or not the source code location from which an event originated is displayed.

This is equivalent to calling Format::with_file and Format::with_line_number with the same value.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Write a log message for Event in Context to the given Writer.

Write a log message for Event in Context to the given Writer.

Write a log message for Event in Context to the given Writer.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into #41263)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.