fmt
and std
only.Expand description
Formatters for logging tracing
events.
This module provides several formatter implementations, as well as utilities for implementing custom formatters.
§Formatters
This module provides a number of formatter implementations:
-
Full
: The default formatter. This emits human-readable, single-line logs for each event that occurs, with the current span context displayed before the formatted representation of the event. See here for sample output. -
Compact
: A variant of the default formatter, optimized for short line lengths. Fields from the current span context are appended to the fields of the formatted event, and span names are not shown; the verbosity level is abbreviated to a single character. See here for sample output. -
Pretty
: Emits excessively pretty, multi-line logs, optimized for human readability. This is primarily intended to be used in local development and debugging, or for command-line applications, where automated analysis and compact storage of logs is less of a priority than readability and visual appeal. See here for sample output. -
Json
: Outputs newline-delimited JSON logs. This is intended for production use with systems where structured logs are consumed as JSON by analysis and viewing tools. The JSON output is not optimized for human readability. See here for sample output.
Structs§
- Compact
- Marker for
Format
that indicates that the compact log format should be used. - Default
Fields - The default
FormatFields
implementation. - Default
Visitor - The visitor produced by
DefaultFields
’sMakeVisitor
implementation. - FieldFn
- A
FormatFields
implementation that formats fields by calling a function or closure. - Field
FnVisitor - The visitor produced by
FieldFn
’sMakeVisitor
implementation. - FmtSpan
- Configures what points in the span lifecycle are logged as events.
- Format
- A pre-configured event formatter.
- Full
- Marker for
Format
that indicates that the default log format should be used. - Json
json
- Marker for
Format
that indicates that the newline-delimited JSON log format should be used. - Json
Fields json
- The JSON
FormatFields
implementation. - Json
Visitor json
- The visitor produced by
JsonFields
’sMakeVisitor
implementation. - Pretty
ansi
- An excessively pretty, human-readable event formatter.
- Pretty
Fields ansi
- An excessively pretty, human-readable
MakeVisitor
implementation. - Pretty
Visitor ansi
- The visitor produced by
Pretty
’sMakeVisitor
implementation. - Writer
- A writer to which formatted representations of spans and events are written.
Traits§
- Format
Event - A type that can format a tracing
Event
to aWriter
. - Format
Fields - A type that can format a set of fields to a
Writer
.
Functions§
- debug_
fn - Returns a
FormatFields
implementation that formats fields using the provided function or closure. - format
- Returns the default configuration for an [event formatter].
- json
json
- Returns the default configuration for a JSON [event formatter].