Struct tracing_subscriber::fmt::format::Format [−][src]
pub struct Format<F = Full, T = SystemTime> { /* fields omitted */ }
fmt
only.Expand description
Implementations
Sets whether or not the source code location from which an event originated is displayed.
This defaults to true
.
This is supported on crate feature ansi
only.
ansi
only.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();
This is supported on crate feature json
only.
json
only.Use the full JSON format.
The full format includes fields from all entered spans.
Example Output
{"timestamp":"Feb 20 11:28:15.096","level":"INFO","target":"mycrate","fields":{"message":"some message", "key": "value"}}
Options
Format::flatten_event
can be used to enable flattening event fields into the root object.
Use the given timer
for log message timestamps.
See time
module for the provided timer implementations.
Note that using the chrono
feature flag enables the
additional time formatters ChronoUtc
and ChronoLocal
.
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
This is supported on crate feature json
only.
json
only.Use the full JSON format with the event’s event fields flattened.
Example Output
{"timestamp":"Feb 20 11:28:15.096","level":"INFO","target":"mycrate", "message":"some message", "key": "value"}
See Json
.
This is supported on crate feature json
only.
json
only.Sets whether or not the formatter will include the current span in formatted events.
See format::Json
This is supported on crate feature json
only.
json
only.Sets whether or not the formatter will include a list (from root to leaf) of all currently entered spans in formatted events.
See format::Json
Trait Implementations
impl<C, N, T> FormatEvent<C, N> for Format<Pretty, T> where
C: Subscriber + for<'a> LookupSpan<'a>,
N: for<'a> FormatFields<'a> + 'static,
T: FormatTime,
impl<C, N, T> FormatEvent<C, N> for Format<Pretty, T> where
C: Subscriber + for<'a> LookupSpan<'a>,
N: for<'a> FormatFields<'a> + 'static,
T: FormatTime,
fn format_event(
&self,
ctx: &FmtContext<'_, C, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result
fn format_event(
&self,
ctx: &FmtContext<'_, C, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result
Write a log message for Event
in Context
to the given Write
.
impl<S, N, T> FormatEvent<S, N> for Format<Json, T> where
S: Subscriber + for<'lookup> LookupSpan<'lookup>,
N: for<'writer> FormatFields<'writer> + 'static,
T: FormatTime,
impl<S, N, T> FormatEvent<S, N> for Format<Json, T> where
S: Subscriber + for<'lookup> LookupSpan<'lookup>,
N: for<'writer> FormatFields<'writer> + 'static,
T: FormatTime,
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result where
S: Subscriber + for<'a> LookupSpan<'a>,
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result where
S: Subscriber + for<'a> LookupSpan<'a>,
Write a log message for Event
in Context
to the given Write
.
impl<S, N, T> FormatEvent<S, N> for Format<Full, T> where
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'a> FormatFields<'a> + 'static,
T: FormatTime,
impl<S, N, T> FormatEvent<S, N> for Format<Full, T> where
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'a> FormatFields<'a> + 'static,
T: FormatTime,
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result
Write a log message for Event
in Context
to the given Write
.
impl<S, N, T> FormatEvent<S, N> for Format<Compact, T> where
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'a> FormatFields<'a> + 'static,
T: FormatTime,
impl<S, N, T> FormatEvent<S, N> for Format<Compact, T> where
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'a> FormatFields<'a> + 'static,
T: FormatTime,
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: &mut dyn Write,
event: &Event<'_>
) -> Result
Write a log message for Event
in Context
to the given Write
.
Auto Trait Implementations
impl<F, T> RefUnwindSafe for Format<F, T> where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<F, T> UnwindSafe for Format<F, T> where
F: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more