tracing_subscriber::fmt

Module format

Source
Available on crate features 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§

Traits§

Functions§

  • Returns a FormatFields implementation that formats fields using the provided function or closure.
  • Returns the default configuration for an [event formatter].
  • jsonjson
    Returns the default configuration for a JSON [event formatter].