summaryrefslogtreecommitdiffstats
path: root/vendor/tracing-subscriber/src/fmt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/fmt_layer.rs (renamed from vendor/tracing-subscriber/src/fmt/fmt_layer.rs)215
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/format/json.rs (renamed from vendor/tracing-subscriber/src/fmt/format/json.rs)175
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/format/mod.rs (renamed from vendor/tracing-subscriber/src/fmt/format/mod.rs)443
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/format/pretty.rs (renamed from vendor/tracing-subscriber/src/fmt/format/pretty.rs)156
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/mod.rs (renamed from vendor/tracing-subscriber/src/fmt/mod.rs)359
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/time/datetime.rs (renamed from vendor/tracing-subscriber/src/fmt/time/datetime.rs)0
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/time/mod.rs (renamed from vendor/tracing-subscriber/src/fmt/time/mod.rs)8
-rw-r--r--vendor/tracing-subscriber-0.3.3/src/fmt/writer.rs (renamed from vendor/tracing-subscriber/src/fmt/writer.rs)28
-rw-r--r--vendor/tracing-subscriber/src/fmt/time/time_crate.rs470
9 files changed, 287 insertions, 1567 deletions
diff --git a/vendor/tracing-subscriber/src/fmt/fmt_layer.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/fmt_layer.rs
index 21992e780..0e0d5e0eb 100644
--- a/vendor/tracing-subscriber/src/fmt/fmt_layer.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/fmt_layer.rs
@@ -56,7 +56,7 @@ use tracing_core::{
/// # tracing::subscriber::set_global_default(subscriber).unwrap();
/// ```
///
-/// [`Layer`]: super::layer::Layer
+/// [`Layer`]: ../layer/trait.Layer.html
#[cfg_attr(docsrs, doc(cfg(all(feature = "fmt", feature = "std"))))]
#[derive(Debug)]
pub struct Layer<
@@ -70,11 +70,11 @@ pub struct Layer<
fmt_event: E,
fmt_span: format::FmtSpanConfig,
is_ansi: bool,
- _inner: PhantomData<fn(S)>,
+ _inner: PhantomData<S>,
}
impl<S> Layer<S> {
- /// Returns a new [`Layer`][self::Layer] with the default configuration.
+ /// Returns a new [`Layer`](struct.Layer.html) with the default configuration.
pub fn new() -> Self {
Self::default()
}
@@ -87,8 +87,8 @@ where
N: for<'writer> FormatFields<'writer> + 'static,
W: for<'writer> MakeWriter<'writer> + 'static,
{
- /// Sets the [event formatter][`FormatEvent`] that the layer being built will
- /// use to format events.
+ /// Sets the [event formatter][`FormatEvent`] that the layer will use to
+ /// format events.
///
/// The event formatter may be any type implementing the [`FormatEvent`]
/// trait, which is implemented for all functions taking a [`FmtContext`], a
@@ -108,7 +108,7 @@ where
/// ```
/// [`FormatEvent`]: format::FormatEvent
/// [`Event`]: tracing::Event
- /// [`Writer`]: format::Writer
+ /// [`Writer`]: crate::format::Writer
pub fn event_format<E2>(self, e: E2) -> Layer<S, N, E2, W>
where
E2: FormatEvent<S, N> + 'static,
@@ -122,40 +122,11 @@ where
_inner: self._inner,
}
}
-
- /// Updates the event formatter by applying a function to the existing event formatter.
- ///
- /// This sets the event formatter that the layer being built will use to record fields.
- ///
- /// # Examples
- ///
- /// Updating an event formatter:
- ///
- /// ```rust
- /// let layer = tracing_subscriber::fmt::layer()
- /// .map_event_format(|e| e.compact());
- /// # // this is necessary for type inference.
- /// # use tracing_subscriber::Layer as _;
- /// # let _ = layer.with_subscriber(tracing_subscriber::registry::Registry::default());
- /// ```
- pub fn map_event_format<E2>(self, f: impl FnOnce(E) -> E2) -> Layer<S, N, E2, W>
- where
- E2: FormatEvent<S, N> + 'static,
- {
- Layer {
- fmt_fields: self.fmt_fields,
- fmt_event: f(self.fmt_event),
- fmt_span: self.fmt_span,
- make_writer: self.make_writer,
- is_ansi: self.is_ansi,
- _inner: self._inner,
- }
- }
}
// This needs to be a seperate impl block because they place different bounds on the type parameters.
impl<S, N, E, W> Layer<S, N, E, W> {
- /// Sets the [`MakeWriter`] that the layer being built will use to write events.
+ /// Sets the [`MakeWriter`] that the [`Layer`] being built will use to write events.
///
/// # Examples
///
@@ -171,6 +142,9 @@ impl<S, N, E, W> Layer<S, N, E, W> {
/// # use tracing_subscriber::Layer as _;
/// # let _ = layer.with_subscriber(tracing_subscriber::registry::Registry::default());
/// ```
+ ///
+ /// [`MakeWriter`]: ../fmt/trait.MakeWriter.html
+ /// [`Layer`]: ../layer/trait.Layer.html
pub fn with_writer<W2>(self, make_writer: W2) -> Layer<S, N, E, W2>
where
W2: for<'writer> MakeWriter<'writer> + 'static,
@@ -185,57 +159,7 @@ impl<S, N, E, W> Layer<S, N, E, W> {
}
}
- /// Borrows the [writer] for this [`Layer`].
- ///
- /// [writer]: MakeWriter
- pub fn writer(&self) -> &W {
- &self.make_writer
- }
-
- /// Mutably borrows the [writer] for this [`Layer`].
- ///
- /// This method is primarily expected to be used with the
- /// [`reload::Handle::modify`](crate::reload::Handle::modify) method.
- ///
- /// # Examples
- ///
- /// ```
- /// # use tracing::info;
- /// # use tracing_subscriber::{fmt,reload,Registry,prelude::*};
- /// # fn non_blocking<T: std::io::Write>(writer: T) -> (fn() -> std::io::Stdout) {
- /// # std::io::stdout
- /// # }
- /// # fn main() {
- /// let layer = fmt::layer().with_writer(non_blocking(std::io::stderr()));
- /// let (layer, reload_handle) = reload::Layer::new(layer);
- /// #
- /// # // specifying the Registry type is required
- /// # let _: &reload::Handle<fmt::Layer<Registry, _, _, _>, Registry> = &reload_handle;
- /// #
- /// info!("This will be logged to stderr");
- /// reload_handle.modify(|layer| *layer.writer_mut() = non_blocking(std::io::stdout()));
- /// info!("This will be logged to stdout");
- /// # }
- /// ```
- ///
- /// [writer]: MakeWriter
- pub fn writer_mut(&mut self) -> &mut W {
- &mut self.make_writer
- }
-
- /// Sets whether this layer should use ANSI terminal formatting
- /// escape codes (such as colors).
- ///
- /// This method is primarily expected to be used with the
- /// [`reload::Handle::modify`](crate::reload::Handle::modify) method when changing
- /// the writer.
- #[cfg(feature = "ansi")]
- #[cfg_attr(docsrs, doc(cfg(feature = "ansi")))]
- pub fn set_ansi(&mut self, ansi: bool) {
- self.is_ansi = ansi;
- }
-
- /// Configures the layer to support [`libtest`'s output capturing][capturing] when used in
+ /// Configures the subscriber to support [`libtest`'s output capturing][capturing] when used in
/// unit tests.
///
/// See [`TestWriter`] for additional details.
@@ -256,7 +180,7 @@ impl<S, N, E, W> Layer<S, N, E, W> {
/// ```
/// [capturing]:
/// https://doc.rust-lang.org/book/ch11-02-running-tests.html#showing-function-output
- /// [`TestWriter`]: super::writer::TestWriter
+ /// [`TestWriter`]: writer/struct.TestWriter.html
pub fn with_test_writer(self) -> Layer<S, N, E, TestWriter> {
Layer {
fmt_fields: self.fmt_fields,
@@ -277,39 +201,6 @@ impl<S, N, E, W> Layer<S, N, E, W> {
..self
}
}
-
- /// Updates the [`MakeWriter`] by applying a function to the existing [`MakeWriter`].
- ///
- /// This sets the [`MakeWriter`] that the layer being built will use to write events.
- ///
- /// # Examples
- ///
- /// Redirect output to stderr if level is <= WARN:
- ///
- /// ```rust
- /// use tracing::Level;
- /// use tracing_subscriber::fmt::{self, writer::MakeWriterExt};
- ///
- /// let stderr = std::io::stderr.with_max_level(Level::WARN);
- /// let layer = fmt::layer()
- /// .map_writer(move |w| stderr.or_else(w));
- /// # // this is necessary for type inference.
- /// # use tracing_subscriber::Layer as _;
- /// # let _ = layer.with_subscriber(tracing_subscriber::registry::Registry::default());
- /// ```
- pub fn map_writer<W2>(self, f: impl FnOnce(W) -> W2) -> Layer<S, N, E, W2>
- where
- W2: for<'writer> MakeWriter<'writer> + 'static,
- {
- Layer {
- fmt_fields: self.fmt_fields,
- fmt_event: self.fmt_event,
- fmt_span: self.fmt_span,
- is_ansi: self.is_ansi,
- make_writer: f(self.make_writer),
- _inner: self._inner,
- }
- }
}
impl<S, N, L, T, W> Layer<S, N, format::Format<L, T>, W>
@@ -393,7 +284,7 @@ where
/// `Layer`s added to this subscriber.
///
/// [lifecycle]: https://docs.rs/tracing/latest/tracing/span/index.html#the-span-lifecycle
- /// [time]: Layer::without_time()
+ /// [time]: #method.without_time
pub fn with_span_events(self, kind: FmtSpan) -> Self {
Layer {
fmt_span: self.fmt_span.with_kind(kind),
@@ -408,30 +299,6 @@ where
..self
}
}
- /// Sets whether or not an event's [source code file path][file] is
- /// displayed.
- ///
- /// [file]: tracing_core::Metadata::file
- pub fn with_file(self, display_filename: bool) -> Layer<S, N, format::Format<L, T>, W> {
- Layer {
- fmt_event: self.fmt_event.with_file(display_filename),
- ..self
- }
- }
-
- /// Sets whether or not an event's [source code line number][line] is
- /// displayed.
- ///
- /// [line]: tracing_core::Metadata::line
- pub fn with_line_number(
- self,
- display_line_number: bool,
- ) -> Layer<S, N, format::Format<L, T>, W> {
- Layer {
- fmt_event: self.fmt_event.with_line_number(display_line_number),
- ..self
- }
- }
/// Sets whether or not an event's level is displayed.
pub fn with_level(self, display_level: bool) -> Layer<S, N, format::Format<L, T>, W> {
@@ -442,9 +309,9 @@ where
}
/// Sets whether or not the [thread ID] of the current thread is displayed
- /// when formatting events.
+ /// when formatting events
///
- /// [thread ID]: std::thread::ThreadId
+ /// [thread ID]: https://doc.rust-lang.org/stable/std/thread/struct.ThreadId.html
pub fn with_thread_ids(self, display_thread_ids: bool) -> Layer<S, N, format::Format<L, T>, W> {
Layer {
fmt_event: self.fmt_event.with_thread_ids(display_thread_ids),
@@ -453,9 +320,9 @@ where
}
/// Sets whether or not the [name] of the current thread is displayed
- /// when formatting events.
+ /// when formatting events
///
- /// [name]: std::thread#naming-threads
+ /// [name]: https://doc.rust-lang.org/stable/std/thread/index.html#naming-threads
pub fn with_thread_names(
self,
display_thread_names: bool,
@@ -466,7 +333,7 @@ where
}
}
- /// Sets the layer being built to use a [less verbose formatter][super::format::Compact].
+ /// Sets the layer being built to use a [less verbose formatter](../fmt/format/struct.Compact.html).
pub fn compact(self) -> Layer<S, N, format::Format<format::Compact, T>, W>
where
N: for<'writer> FormatFields<'writer> + 'static,
@@ -495,7 +362,7 @@ where
}
}
- /// Sets the layer being built to use a [JSON formatter][super::format::Json].
+ /// Sets the layer being built to use a [JSON formatter](../fmt/format/struct.Json.html).
///
/// The full format includes fields from all entered spans.
///
@@ -510,7 +377,7 @@ where
/// - [`Layer::flatten_event`] can be used to enable flattening event fields into the root
/// object.
///
- /// [`Layer::flatten_event`]: Layer::flatten_event()
+ /// [`Layer::flatten_event`]: #method.flatten_event
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn json(self) -> Layer<S, format::JsonFields, format::Format<format::Json, T>, W> {
@@ -531,7 +398,7 @@ where
impl<S, T, W> Layer<S, format::JsonFields, format::Format<format::Json, T>, W> {
/// Sets the JSON layer being built to flatten event metadata.
///
- /// See [`format::Json`][super::format::Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
pub fn flatten_event(
self,
flatten_event: bool,
@@ -546,7 +413,7 @@ impl<S, T, W> Layer<S, format::JsonFields, format::Format<format::Json, T>, W> {
/// Sets whether or not the formatter will include the current span in
/// formatted events.
///
- /// See [`format::Json`][super::format::Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
pub fn with_current_span(
self,
display_current_span: bool,
@@ -561,7 +428,7 @@ impl<S, T, W> Layer<S, format::JsonFields, format::Format<format::Json, T>, W> {
/// 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`][super::format::Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
pub fn with_span_list(
self,
display_span_list: bool,
@@ -590,36 +457,6 @@ impl<S, N, E, W> Layer<S, N, E, W> {
_inner: self._inner,
}
}
-
- /// Updates the field formatter by applying a function to the existing field formatter.
- ///
- /// This sets the field formatter that the layer being built will use to record fields.
- ///
- /// # Examples
- ///
- /// Updating a field formatter:
- ///
- /// ```rust
- /// use tracing_subscriber::field::MakeExt;
- /// let layer = tracing_subscriber::fmt::layer()
- /// .map_fmt_fields(|f| f.debug_alt());
- /// # // this is necessary for type inference.
- /// # use tracing_subscriber::Layer as _;
- /// # let _ = layer.with_subscriber(tracing_subscriber::registry::Registry::default());
- /// ```
- pub fn map_fmt_fields<N2>(self, f: impl FnOnce(N) -> N2) -> Layer<S, N2, E, W>
- where
- N2: for<'writer> FormatFields<'writer> + 'static,
- {
- Layer {
- fmt_event: self.fmt_event,
- fmt_fields: f(self.fmt_fields),
- fmt_span: self.fmt_span,
- make_writer: self.make_writer,
- is_ansi: self.is_ansi,
- _inner: self._inner,
- }
- }
}
impl<S> Default for Layer<S> {
@@ -660,7 +497,7 @@ where
/// formatters are in use, each can store its own formatted representation
/// without conflicting.
///
-/// [extensions]: crate::registry::Extensions
+/// [extensions]: ../registry/struct.Extensions.html
#[derive(Default)]
pub struct FormattedFields<E: ?Sized> {
_format_fields: PhantomData<fn(E)>,
@@ -984,7 +821,7 @@ where
/// If this returns `None`, then no span exists for that ID (either it has
/// closed or the ID is invalid).
///
- /// [stored data]: crate::registry::SpanRef
+ /// [stored data]: ../registry/struct.SpanRef.html
#[inline]
pub fn span(&self, id: &Id) -> Option<SpanRef<'_, S>>
where
@@ -1007,7 +844,7 @@ where
///
/// If this returns `None`, then we are not currently within a span.
///
- /// [stored data]: crate::registry::SpanRef
+ /// [stored data]: ../registry/struct.SpanRef.html
#[inline]
pub fn lookup_current(&self) -> Option<SpanRef<'_, S>>
where
diff --git a/vendor/tracing-subscriber/src/fmt/format/json.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/format/json.rs
index c2f4d3755..cc86f03c7 100644
--- a/vendor/tracing-subscriber/src/fmt/format/json.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/format/json.rs
@@ -23,42 +23,25 @@ use tracing_serde::AsSerde;
#[cfg(feature = "tracing-log")]
use tracing_log::NormalizeEvent;
-/// Marker for [`Format`] that indicates that the newline-delimited JSON log
-/// format should be used.
+/// Marker for `Format` that indicates that the verbose JSON log format should be used.
///
-/// This formatter 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; instead, it should be pretty-printed
-/// using external JSON tools such as `jq`, or using a JSON log viewer.
+/// The full format includes fields from all entered spans.
///
/// # Example Output
///
-/// <pre><font color="#4E9A06"><b>:;</b></font> <font color="#4E9A06">cargo</font> run --example fmt-json
-/// <font color="#4E9A06"><b> Finished</b></font> dev [unoptimized + debuginfo] target(s) in 0.08s
-/// <font color="#4E9A06"><b> Running</b></font> `target/debug/examples/fmt-json`
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821315Z&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;preparing to shave yaks&quot;,&quot;number_of_yaks&quot;:3},&quot;target&quot;:&quot;fmt_json&quot;}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821422Z&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;shaving yaks&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821495Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;hello! I&apos;m gonna shave a yak&quot;,&quot;excitement&quot;:&quot;yay!&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:1,&quot;name&quot;:&quot;shave&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821546Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;yak shaved successfully&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:1,&quot;name&quot;:&quot;shave&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821598Z&quot;,&quot;level&quot;:&quot;DEBUG&quot;,&quot;fields&quot;:{&quot;yak&quot;:1,&quot;shaved&quot;:true},&quot;target&quot;:&quot;yak_events&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821637Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;yaks_shaved&quot;:1},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821684Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;hello! I&apos;m gonna shave a yak&quot;,&quot;excitement&quot;:&quot;yay!&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:2,&quot;name&quot;:&quot;shave&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821727Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;yak shaved successfully&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:2,&quot;name&quot;:&quot;shave&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821773Z&quot;,&quot;level&quot;:&quot;DEBUG&quot;,&quot;fields&quot;:{&quot;yak&quot;:2,&quot;shaved&quot;:true},&quot;target&quot;:&quot;yak_events&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821806Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;yaks_shaved&quot;:2},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821909Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;hello! I&apos;m gonna shave a yak&quot;,&quot;excitement&quot;:&quot;yay!&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:3,&quot;name&quot;:&quot;shave&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.821956Z&quot;,&quot;level&quot;:&quot;WARN&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;could not locate yak&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:3,&quot;name&quot;:&quot;shave&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.822006Z&quot;,&quot;level&quot;:&quot;DEBUG&quot;,&quot;fields&quot;:{&quot;yak&quot;:3,&quot;shaved&quot;:false},&quot;target&quot;:&quot;yak_events&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.822041Z&quot;,&quot;level&quot;:&quot;ERROR&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;failed to shave yak&quot;,&quot;yak&quot;:3,&quot;error&quot;:&quot;missing yak&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.822079Z&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;yaks_shaved&quot;:2},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
-/// {&quot;timestamp&quot;:&quot;2022-02-15T18:47:10.822117Z&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;yak shaving completed&quot;,&quot;all_yaks_shaved&quot;:false},&quot;target&quot;:&quot;fmt_json&quot;}
-/// </pre>
+/// ```json
+/// {
+/// "timestamp":"Feb 20 11:28:15.096",
+/// "level":"INFO",
+/// "fields":{"message":"some message","key":"value"}
+/// "target":"mycrate",
+/// "span":{name":"leaf"},
+/// "spans":[{"name":"root"},{"name":"leaf"}],
+/// }
+/// ```
///
/// # Options
///
-/// This formatter exposes additional options to configure the structure of the
-/// output JSON objects:
-///
/// - [`Json::flatten_event`] can be used to enable flattening event fields into
/// the root
/// - [`Json::with_current_span`] can be used to control logging of the current
@@ -69,23 +52,9 @@ use tracing_log::NormalizeEvent;
/// By default, event fields are not flattened, and both current span and span
/// list are logged.
///
-/// # Valuable Support
-///
-/// Experimental support is available for using the [`valuable`] crate to record
-/// user-defined values as structured JSON. When the ["valuable" unstable
-/// feature][unstable] is enabled, types implementing [`valuable::Valuable`] will
-/// be recorded as structured JSON, rather than
-/// using their [`std::fmt::Debug`] implementations.
-///
-/// **Note**: This is an experimental feature. [Unstable features][unstable]
-/// must be enabled in order to use `valuable` support.
-///
-/// [`Json::flatten_event`]: Json::flatten_event()
-/// [`Json::with_current_span`]: Json::with_current_span()
-/// [`Json::with_span_list`]: Json::with_span_list()
-/// [`valuable`]: https://crates.io/crates/valuable
-/// [unstable]: crate#unstable-features
-/// [`valuable::Valuable`]: https://docs.rs/valuable/latest/valuable/trait.Valuable.html
+/// [`Json::flatten_event`]: #method.flatten_event
+/// [`Json::with_current_span`]: #method.with_current_span
+/// [`Json::with_span_list`]: #method.with_span_list
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Json {
pub(crate) flatten_event: bool,
@@ -274,18 +243,6 @@ where
serializer.serialize_entry("target", meta.target())?;
}
- if self.display_filename {
- if let Some(filename) = meta.file() {
- serializer.serialize_entry("filename", filename)?;
- }
- }
-
- if self.display_line_number {
- if let Some(line_number) = meta.line() {
- serializer.serialize_entry("line_number", &line_number)?;
- }
- }
-
if self.format.display_current_span {
if let Some(ref span) = current_span {
serializer
@@ -341,6 +298,7 @@ impl Default for Json {
/// The JSON [`FormatFields`] implementation.
///
+/// [`FormatFields`]: trait.FormatFields.html
#[derive(Debug)]
pub struct JsonFields {
// reserve the ability to add fields to this without causing a breaking
@@ -351,6 +309,7 @@ pub struct JsonFields {
impl JsonFields {
/// Returns a new JSON [`FormatFields`] implementation.
///
+ /// [`FormatFields`]: trait.FormatFields.html
pub fn new() -> Self {
Self { _private: () }
}
@@ -419,8 +378,9 @@ impl<'a> FormatFields<'a> for JsonFields {
/// The [visitor] produced by [`JsonFields`]'s [`MakeVisitor`] implementation.
///
-/// [visitor]: crate::field::Visit
-/// [`MakeVisitor`]: crate::field::MakeVisitor
+/// [visitor]: ../../field/trait.Visit.html
+/// [`JsonFields`]: struct.JsonFields.html
+/// [`MakeVisitor`]: ../../field/trait.MakeVisitor.html
pub struct JsonVisitor<'a> {
values: BTreeMap<&'a str, serde_json::Value>,
writer: &'a mut dyn Write,
@@ -475,26 +435,6 @@ impl<'a> crate::field::VisitOutput<fmt::Result> for JsonVisitor<'a> {
}
impl<'a> field::Visit for JsonVisitor<'a> {
- #[cfg(all(tracing_unstable, feature = "valuable"))]
- fn record_value(&mut self, field: &Field, value: valuable_crate::Value<'_>) {
- let value = match serde_json::to_value(valuable_serde::Serializable::new(value)) {
- Ok(value) => value,
- Err(_e) => {
- #[cfg(debug_assertions)]
- unreachable!(
- "`valuable::Valuable` implementations should always serialize \
- successfully, but an error occurred: {}",
- _e,
- );
-
- #[cfg(not(debug_assertions))]
- return;
- }
- };
-
- self.values.insert(field.name(), value);
- }
-
/// Visit a double precision floating point value.
fn record_f64(&mut self, field: &Field, value: f64) {
self.values
@@ -548,7 +488,6 @@ mod test {
use tracing::{self, subscriber::with_default};
use std::fmt;
- use std::path::Path;
struct MockTime;
impl FormatTime for MockTime {
@@ -577,50 +516,6 @@ mod test {
}
#[test]
- fn json_filename() {
- let current_path = Path::new("tracing-subscriber")
- .join("src")
- .join("fmt")
- .join("format")
- .join("json.rs")
- .to_str()
- .expect("path must be valid unicode")
- // escape windows backslashes
- .replace('\\', "\\\\");
- let expected =
- &format!("{}{}{}",
- "{\"timestamp\":\"fake time\",\"level\":\"INFO\",\"span\":{\"answer\":42,\"name\":\"json_span\",\"number\":3},\"spans\":[{\"answer\":42,\"name\":\"json_span\",\"number\":3}],\"target\":\"tracing_subscriber::fmt::format::json::test\",\"filename\":\"",
- current_path,
- "\",\"fields\":{\"message\":\"some json test\"}}\n");
- let subscriber = subscriber()
- .flatten_event(false)
- .with_current_span(true)
- .with_file(true)
- .with_span_list(true);
- test_json(expected, subscriber, || {
- let span = tracing::span!(tracing::Level::INFO, "json_span", answer = 42, number = 3);
- let _guard = span.enter();
- tracing::info!("some json test");
- });
- }
-
- #[test]
- fn json_line_number() {
- let expected =
- "{\"timestamp\":\"fake time\",\"level\":\"INFO\",\"span\":{\"answer\":42,\"name\":\"json_span\",\"number\":3},\"spans\":[{\"answer\":42,\"name\":\"json_span\",\"number\":3}],\"target\":\"tracing_subscriber::fmt::format::json::test\",\"line_number\":42,\"fields\":{\"message\":\"some json test\"}}\n";
- let subscriber = subscriber()
- .flatten_event(false)
- .with_current_span(true)
- .with_line_number(true)
- .with_span_list(true);
- test_json_with_line_number(expected, subscriber, || {
- let span = tracing::span!(tracing::Level::INFO, "json_span", answer = 42, number = 3);
- let _guard = span.enter();
- tracing::info!("some json test");
- });
- }
-
- #[test]
fn json_flattened_event() {
let expected =
"{\"timestamp\":\"fake time\",\"level\":\"INFO\",\"span\":{\"answer\":42,\"name\":\"json_span\",\"number\":3},\"spans\":[{\"answer\":42,\"name\":\"json_span\",\"number\":3}],\"target\":\"tracing_subscriber::fmt::format::json::test\",\"message\":\"some json test\"}\n";
@@ -852,34 +747,4 @@ mod test {
serde_json::from_str(actual).unwrap()
);
}
-
- fn test_json_with_line_number<T>(
- expected: &str,
- builder: crate::fmt::SubscriberBuilder<JsonFields, Format<Json>>,
- producer: impl FnOnce() -> T,
- ) {
- let make_writer = MockMakeWriter::default();
- let subscriber = builder
- .with_writer(make_writer.clone())
- .with_timer(MockTime)
- .finish();
-
- with_default(subscriber, producer);
-
- let buf = make_writer.buf();
- let actual = std::str::from_utf8(&buf[..]).unwrap();
- let mut expected =
- serde_json::from_str::<std::collections::HashMap<&str, serde_json::Value>>(expected)
- .unwrap();
- let expect_line_number = expected.remove("line_number").is_some();
- let mut actual: std::collections::HashMap<&str, serde_json::Value> =
- serde_json::from_str(actual).unwrap();
- let line_number = actual.remove("line_number");
- if expect_line_number {
- assert_eq!(line_number.map(|x| x.is_number()), Some(true));
- } else {
- assert!(line_number.is_none());
- }
- assert_eq!(actual, expected);
- }
}
diff --git a/vendor/tracing-subscriber/src/fmt/format/mod.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/format/mod.rs
index ec79ac140..9001e102e 100644
--- a/vendor/tracing-subscriber/src/fmt/format/mod.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/format/mod.rs
@@ -1,33 +1,4 @@
//! 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](Full#example-output) 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](Compact#example-output) 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](Pretty#example-output)
-//! 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](Json#example-output) for sample output.
use super::time::{FormatTime, SystemTime};
use crate::{
field::{MakeOutput, MakeVisitor, RecordFields, VisitFmt, VisitOutput},
@@ -182,7 +153,6 @@ pub use pretty::*;
/// DEBUG yak_shaving::shaver: some-span{field-on-span=foo}: started shaving yak
/// ```
///
-/// [`layer::Context`]: crate::layer::Context
/// [`fmt::Layer`]: super::Layer
/// [`fmt::Subscriber`]: super::Subscriber
/// [`Event`]: tracing::Event
@@ -227,8 +197,8 @@ where
/// time a span or event with fields is recorded, the subscriber will format
/// those fields with its associated `FormatFields` implementation.
///
-/// [set of fields]: crate::field::RecordFields
-/// [`FmtSubscriber`]: super::Subscriber
+/// [set of fields]: ../field/trait.RecordFields.html
+/// [`FmtSubscriber`]: ../fmt/struct.Subscriber.html
pub trait FormatFields<'writer> {
/// Format the provided `fields` to the provided [`Writer`], returning a result.
fn format_fields<R: RecordFields>(&self, writer: Writer<'writer>, fields: R) -> fmt::Result;
@@ -281,6 +251,7 @@ pub fn json() -> Format<Json> {
/// Returns a [`FormatFields`] implementation that formats fields using the
/// provided function or closure.
///
+/// [`FormatFields`]: trait.FormatFields.html
pub fn debug_fn<F>(f: F) -> FieldFn<F>
where
F: Fn(&mut Writer<'_>, &Field, &dyn fmt::Debug) -> fmt::Result + Clone,
@@ -301,8 +272,6 @@ where
///
/// Additionally, a `Writer` may expose additional `tracing`-specific
/// information to the formatter implementation.
-///
-/// [fields]: tracing_core::field
pub struct Writer<'writer> {
writer: &'writer mut dyn fmt::Write,
// TODO(eliza): add ANSI support
@@ -312,76 +281,28 @@ pub struct Writer<'writer> {
/// A [`FormatFields`] implementation that formats fields by calling a function
/// or closure.
///
+/// [`FormatFields`]: trait.FormatFields.html
#[derive(Debug, Clone)]
pub struct FieldFn<F>(F);
/// The [visitor] produced by [`FieldFn`]'s [`MakeVisitor`] implementation.
///
-/// [visitor]: super::super::field::Visit
-/// [`MakeVisitor`]: super::super::field::MakeVisitor
+/// [visitor]: ../../field/trait.Visit.html
+/// [`FieldFn`]: struct.FieldFn.html
+/// [`MakeVisitor`]: ../../field/trait.MakeVisitor.html
pub struct FieldFnVisitor<'a, F> {
f: F,
writer: Writer<'a>,
result: fmt::Result,
}
-/// Marker for [`Format`] that indicates that the compact log format should be used.
-///
-/// The compact format includes fields from all currently entered spans, after
-/// the event's fields. Span names are listed in order before fields are
-/// displayed.
-///
-/// # Example Output
+/// Marker for `Format` that indicates that the compact log format should be used.
///
-/// <pre><font color="#4E9A06"><b>:;</b></font> <font color="#4E9A06">cargo</font> run --example fmt-compact
-/// <font color="#4E9A06"><b> Finished</b></font> dev [unoptimized + debuginfo] target(s) in 0.08s
-/// <font color="#4E9A06"><b> Running</b></font> `target/debug/examples/fmt-compact`
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809287Z </font><font color="#4E9A06"> INFO</font> <b>fmt_compact</b><font color="#AAAAAA">: preparing to shave yaks </font><i>number_of_yaks</i><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809367Z </font><font color="#4E9A06"> INFO</font> <b>shaving_yaks</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: shaving yaks </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809414Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>:<b>shave</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: hello! I&apos;m gonna shave a yak </font><i>excitement</i><font color="#AAAAAA">=&quot;yay!&quot; </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3 </font><font color="#AAAAAA"><i>yak</i></font><font color="#AAAAAA">=1</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809443Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>:<b>shave</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: yak shaved successfully </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3 </font><font color="#AAAAAA"><i>yak</i></font><font color="#AAAAAA">=1</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809477Z </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks</b>: <b>yak_events</b><font color="#AAAAAA">: </font><i>yak</i><font color="#AAAAAA">=1 </font><i>shaved</i><font color="#AAAAAA">=true </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809500Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: </font><i>yaks_shaved</i><font color="#AAAAAA">=1 </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809531Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>:<b>shave</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: hello! I&apos;m gonna shave a yak </font><i>excitement</i><font color="#AAAAAA">=&quot;yay!&quot; </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3 </font><font color="#AAAAAA"><i>yak</i></font><font color="#AAAAAA">=2</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809554Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>:<b>shave</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: yak shaved successfully </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3 </font><font color="#AAAAAA"><i>yak</i></font><font color="#AAAAAA">=2</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809581Z </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks</b>: <b>yak_events</b><font color="#AAAAAA">: </font><i>yak</i><font color="#AAAAAA">=2 </font><i>shaved</i><font color="#AAAAAA">=true </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809606Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: </font><i>yaks_shaved</i><font color="#AAAAAA">=2 </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809635Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>:<b>shave</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: hello! I&apos;m gonna shave a yak </font><i>excitement</i><font color="#AAAAAA">=&quot;yay!&quot; </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3 </font><font color="#AAAAAA"><i>yak</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809664Z </font><font color="#C4A000"> WARN</font> <b>shaving_yaks</b>:<b>shave</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: could not locate yak </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3 </font><font color="#AAAAAA"><i>yak</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809693Z </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks</b>: <b>yak_events</b><font color="#AAAAAA">: </font><i>yak</i><font color="#AAAAAA">=3 </font><i>shaved</i><font color="#AAAAAA">=false </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809717Z </font><font color="#CC0000">ERROR</font> <b>shaving_yaks</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: failed to shave yak </font><i>yak</i><font color="#AAAAAA">=3 </font><i>error</i><font color="#AAAAAA">=missing yak </font><i>error.sources</i><font color="#AAAAAA">=[out of space, out of cash] </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809743Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks</b>: <b>fmt_compact::yak_shave</b><font color="#AAAAAA">: </font><i>yaks_shaved</i><font color="#AAAAAA">=2 </font><font color="#AAAAAA"><i>yaks</i></font><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-17T19:51:05.809768Z </font><font color="#4E9A06"> INFO</font> <b>fmt_compact</b><font color="#AAAAAA">: yak shaving completed </font><i>all_yaks_shaved</i><font color="#AAAAAA">=false</font>
-///
-/// </pre>
+/// The compact format only includes the fields from the most recently entered span.
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
pub struct Compact;
-/// Marker for [`Format`] that indicates that the default log format should be used.
-///
-/// This formatter shows the span context before printing event data. Spans are
-/// displayed including their names and fields.
+/// Marker for `Format` that indicates that the verbose log format should be used.
///
-/// # Example Output
-///
-/// <pre><font color="#4E9A06"><b>:;</b></font> <font color="#4E9A06">cargo</font> run --example fmt
-/// <font color="#4E9A06"><b> Finished</b></font> dev [unoptimized + debuginfo] target(s) in 0.08s
-/// <font color="#4E9A06"><b> Running</b></font> `target/debug/examples/fmt`
-/// <font color="#AAAAAA">2022-02-15T18:40:14.289898Z </font><font color="#4E9A06"> INFO</font> fmt: preparing to shave yaks <i>number_of_yaks</i><font color="#AAAAAA">=3</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.289974Z </font><font color="#4E9A06"> INFO</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: shaving yaks</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290011Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">:</font><b>shave{</b><i>yak</i><font color="#AAAAAA">=1</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: hello! I&apos;m gonna shave a yak </font><i>excitement</i><font color="#AAAAAA">=&quot;yay!&quot;</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290038Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">:</font><b>shave{</b><i>yak</i><font color="#AAAAAA">=1</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: yak shaved successfully</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290070Z </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: yak_events: </font><i>yak</i><font color="#AAAAAA">=1 </font><i>shaved</i><font color="#AAAAAA">=true</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290089Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: </font><i>yaks_shaved</i><font color="#AAAAAA">=1</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290114Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">:</font><b>shave{</b><i>yak</i><font color="#AAAAAA">=2</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: hello! I&apos;m gonna shave a yak </font><i>excitement</i><font color="#AAAAAA">=&quot;yay!&quot;</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290134Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">:</font><b>shave{</b><i>yak</i><font color="#AAAAAA">=2</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: yak shaved successfully</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290157Z </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: yak_events: </font><i>yak</i><font color="#AAAAAA">=2 </font><i>shaved</i><font color="#AAAAAA">=true</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290174Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: </font><i>yaks_shaved</i><font color="#AAAAAA">=2</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290198Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">:</font><b>shave{</b><i>yak</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: hello! I&apos;m gonna shave a yak </font><i>excitement</i><font color="#AAAAAA">=&quot;yay!&quot;</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290222Z </font><font color="#C4A000"> WARN</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">:</font><b>shave{</b><i>yak</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: could not locate yak</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290247Z </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: yak_events: </font><i>yak</i><font color="#AAAAAA">=3 </font><i>shaved</i><font color="#AAAAAA">=false</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290268Z </font><font color="#CC0000">ERROR</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: failed to shave yak </font><i>yak</i><font color="#AAAAAA">=3 </font><i>error</i><font color="#AAAAAA">=missing yak </font><i>error.sources</i><font color="#AAAAAA">=[out of space, out of cash]</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290287Z </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b><i>yaks</i><font color="#AAAAAA">=3</font><b>}</b><font color="#AAAAAA">: fmt::yak_shave: </font><i>yaks_shaved</i><font color="#AAAAAA">=2</font>
-/// <font color="#AAAAAA">2022-02-15T18:40:14.290309Z </font><font color="#4E9A06"> INFO</font> fmt: yak shaving completed. <i>all_yaks_shaved</i><font color="#AAAAAA">=false</font>
-/// </pre>
+/// The full format includes fields from all entered spans.
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
pub struct Full;
@@ -390,11 +311,8 @@ pub struct Full;
/// 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.
+/// spans. The [`Compact`] logging format includes only the fields from the most-recently-entered
+/// span.
#[derive(Debug, Clone)]
pub struct Format<F = Full, T = SystemTime> {
format: F,
@@ -405,8 +323,6 @@ pub struct Format<F = Full, T = SystemTime> {
pub(crate) display_level: bool,
pub(crate) display_thread_id: bool,
pub(crate) display_thread_name: bool,
- pub(crate) display_filename: bool,
- pub(crate) display_line_number: bool,
}
// === impl Writer ===
@@ -583,8 +499,6 @@ impl Default for Format<Full, SystemTime> {
display_level: true,
display_thread_id: false,
display_thread_name: false,
- display_filename: false,
- display_line_number: false,
}
}
}
@@ -603,8 +517,6 @@ impl<F, T> Format<F, T> {
display_level: self.display_level,
display_thread_id: self.display_thread_id,
display_thread_name: self.display_thread_name,
- display_filename: self.display_filename,
- display_line_number: self.display_line_number,
}
}
@@ -642,8 +554,6 @@ impl<F, T> Format<F, T> {
display_level: self.display_level,
display_thread_id: self.display_thread_id,
display_thread_name: self.display_thread_name,
- display_filename: true,
- display_line_number: true,
}
}
@@ -661,6 +571,8 @@ impl<F, T> Format<F, T> {
///
/// - [`Format::flatten_event`] can be used to enable flattening event fields into the root
/// object.
+ ///
+ /// [`Format::flatten_event`]: #method.flatten_event
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn json(self) -> Format<Json, T> {
@@ -673,8 +585,6 @@ impl<F, T> Format<F, T> {
display_level: self.display_level,
display_thread_id: self.display_thread_id,
display_thread_name: self.display_thread_name,
- display_filename: self.display_filename,
- display_line_number: self.display_line_number,
}
}
@@ -702,8 +612,6 @@ impl<F, T> Format<F, T> {
display_level: self.display_level,
display_thread_id: self.display_thread_id,
display_thread_name: self.display_thread_name,
- display_filename: self.display_filename,
- display_line_number: self.display_line_number,
}
}
@@ -718,8 +626,6 @@ impl<F, T> Format<F, T> {
display_level: self.display_level,
display_thread_id: self.display_thread_id,
display_thread_name: self.display_thread_name,
- display_filename: self.display_filename,
- display_line_number: self.display_line_number,
}
}
@@ -748,9 +654,9 @@ impl<F, T> Format<F, T> {
}
/// Sets whether or not the [thread ID] of the current thread is displayed
- /// when formatting events.
+ /// when formatting events
///
- /// [thread ID]: std::thread::ThreadId
+ /// [thread ID]: https://doc.rust-lang.org/stable/std/thread/struct.ThreadId.html
pub fn with_thread_ids(self, display_thread_id: bool) -> Format<F, T> {
Format {
display_thread_id,
@@ -759,9 +665,9 @@ impl<F, T> Format<F, T> {
}
/// Sets whether or not the [name] of the current thread is displayed
- /// when formatting events.
+ /// when formatting events
///
- /// [name]: std::thread#naming-threads
+ /// [name]: https://doc.rust-lang.org/stable/std/thread/index.html#naming-threads
pub fn with_thread_names(self, display_thread_name: bool) -> Format<F, T> {
Format {
display_thread_name,
@@ -769,38 +675,6 @@ impl<F, T> Format<F, T> {
}
}
- /// Sets whether or not an event's [source code file path][file] is
- /// displayed.
- ///
- /// [file]: tracing_core::Metadata::file
- pub fn with_file(self, display_filename: bool) -> Format<F, T> {
- Format {
- display_filename,
- ..self
- }
- }
-
- /// Sets whether or not an event's [source code line number][line] is
- /// displayed.
- ///
- /// [line]: tracing_core::Metadata::line
- pub fn with_line_number(self, display_line_number: bool) -> Format<F, T> {
- Format {
- display_line_number,
- ..self
- }
- }
-
- /// 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.
- pub fn with_source_location(self, display_location: bool) -> Self {
- self.with_line_number(display_location)
- .with_file(display_location)
- }
-
#[inline]
fn format_timestamp(&self, writer: &mut Writer<'_>) -> fmt::Result
where
@@ -818,24 +692,14 @@ impl<F, T> Format<F, T> {
if writer.has_ansi_escapes() {
let style = Style::new().dimmed();
write!(writer, "{}", style.prefix())?;
-
- // If getting the timestamp failed, don't bail --- only bail on
- // formatting errors.
- if self.timer.format_time(writer).is_err() {
- writer.write_str("<unknown time>")?;
- }
-
+ self.timer.format_time(writer)?;
write!(writer, "{} ", style.suffix())?;
return Ok(());
}
}
// Otherwise, just format the timestamp without ANSI formatting.
- // If getting the timestamp failed, don't bail --- only bail on
- // formatting errors.
- if self.timer.format_time(writer).is_err() {
- writer.write_str("<unknown time>")?;
- }
+ self.timer.format_time(writer)?;
writer.write_char(' ')
}
}
@@ -850,7 +714,7 @@ impl<T> Format<Json, T> {
/// ```ignore,json
/// {"timestamp":"Feb 20 11:28:15.096","level":"INFO","target":"mycrate", "message":"some message", "key": "value"}
/// ```
- /// See [`Json`][super::format::Json].
+ /// See [`Json`](../format/struct.Json.html).
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn flatten_event(mut self, flatten_event: bool) -> Format<Json, T> {
@@ -861,7 +725,7 @@ impl<T> Format<Json, T> {
/// Sets whether or not the formatter will include the current span in
/// formatted events.
///
- /// See [`format::Json`][Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn with_current_span(mut self, display_current_span: bool) -> Format<Json, T> {
@@ -872,7 +736,7 @@ impl<T> Format<Json, T> {
/// 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`][Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn with_span_list(mut self, display_span_list: bool) -> Format<Json, T> {
@@ -976,34 +840,6 @@ where
)?;
}
- let line_number = if self.display_line_number {
- meta.line()
- } else {
- None
- };
-
- if self.display_filename {
- if let Some(filename) = meta.file() {
- write!(
- writer,
- "{}{}{}",
- dimmed.paint(filename),
- dimmed.paint(":"),
- if line_number.is_some() { "" } else { " " }
- )?;
- }
- }
-
- if let Some(line_number) = line_number {
- write!(
- writer,
- "{}{}:{} ",
- dimmed.prefix(),
- line_number,
- dimmed.suffix()
- )?;
- }
-
ctx.format_fields(writer.by_ref(), event)?;
writeln!(writer)
}
@@ -1082,49 +918,23 @@ where
};
write!(writer, "{}", fmt_ctx)?;
- let bold = writer.bold();
- let dimmed = writer.dimmed();
-
- let mut needs_space = false;
if self.display_target {
- write!(writer, "{}{}", bold.paint(meta.target()), dimmed.paint(":"))?;
- needs_space = true;
- }
-
- if self.display_filename {
- if let Some(filename) = meta.file() {
- if self.display_target {
- writer.write_char(' ')?;
- }
- write!(writer, "{}{}", bold.paint(filename), dimmed.paint(":"))?;
- needs_space = true;
- }
- }
-
- if self.display_line_number {
- if let Some(line_number) = meta.line() {
- write!(
- writer,
- "{}{}{}{}",
- bold.prefix(),
- line_number,
- bold.suffix(),
- dimmed.paint(":")
- )?;
- needs_space = true;
- }
- }
-
- if needs_space {
- writer.write_char(' ')?;
+ write!(
+ writer,
+ "{}{} ",
+ writer.bold().paint(meta.target()),
+ writer.dimmed().paint(":")
+ )?;
}
ctx.format_fields(writer.by_ref(), event)?;
+ let dimmed = writer.dimmed();
for span in ctx
.event_scope()
.into_iter()
- .flat_map(crate::registry::Scope::from_root)
+ .map(crate::registry::Scope::from_root)
+ .flatten()
{
let exts = span.extensions();
if let Some(fields) = exts.get::<FormattedFields<N>>() {
@@ -1152,6 +962,7 @@ where
/// The default [`FormatFields`] implementation.
///
+/// [`FormatFields`]: trait.FormatFields.html
#[derive(Debug)]
pub struct DefaultFields {
// reserve the ability to add fields to this without causing a breaking
@@ -1173,6 +984,7 @@ pub struct DefaultVisitor<'a> {
impl DefaultFields {
/// Returns a new default [`FormatFields`] implementation.
///
+ /// [`FormatFields`]: trait.FormatFields.html
pub fn new() -> Self {
Self { _private: () }
}
@@ -1389,14 +1201,6 @@ impl Style {
fn paint(&self, d: impl fmt::Display) -> impl fmt::Display {
d
}
-
- fn prefix(&self) -> impl fmt::Display {
- ""
- }
-
- fn suffix(&self) -> impl fmt::Display {
- ""
- }
}
struct FmtThreadName<'a> {
@@ -1562,7 +1366,7 @@ impl<'a, F> fmt::Debug for FieldFnVisitor<'a, F> {
/// Configures what points in the span lifecycle are logged as events.
///
-/// See also [`with_span_events`](super::SubscriberBuilder.html::with_span_events).
+/// See also [`with_span_events`](../struct.SubscriberBuilder.html#method.with_span_events).
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct FmtSpan(u8);
@@ -1724,9 +1528,7 @@ pub(super) mod test {
};
use super::*;
-
- use regex::Regex;
- use std::{fmt, path::Path};
+ use std::fmt;
pub(crate) struct MockTime;
impl FormatTime for MockTime {
@@ -1748,7 +1550,7 @@ pub(super) mod test {
.with_thread_names(false);
#[cfg(feature = "ansi")]
let subscriber = subscriber.with_ansi(false);
- assert_info_hello(subscriber, make_writer, "hello\n")
+ run_test(subscriber, make_writer, "hello\n")
}
fn test_ansi<T>(
@@ -1796,124 +1598,6 @@ pub(super) mod test {
run_test(subscriber, make_writer, expected);
}
- #[test]
- fn with_line_number_and_file_name() {
- let make_writer = MockMakeWriter::default();
- let subscriber = crate::fmt::Subscriber::builder()
- .with_writer(make_writer.clone())
- .with_file(true)
- .with_line_number(true)
- .with_level(false)
- .with_ansi(false)
- .with_timer(MockTime);
-
- let expected = Regex::new(&format!(
- "^fake time tracing_subscriber::fmt::format::test: {}:[0-9]+: hello\n$",
- current_path()
- // if we're on Windows, the path might contain backslashes, which
- // have to be escpaed before compiling the regex.
- .replace('\\', "\\\\")
- ))
- .unwrap();
- let _default = set_default(&subscriber.into());
- tracing::info!("hello");
- let res = make_writer.get_string();
- assert!(expected.is_match(&res));
- }
-
- #[test]
- fn with_line_number() {
- let make_writer = MockMakeWriter::default();
- let subscriber = crate::fmt::Subscriber::builder()
- .with_writer(make_writer.clone())
- .with_line_number(true)
- .with_level(false)
- .with_ansi(false)
- .with_timer(MockTime);
-
- let expected =
- Regex::new("^fake time tracing_subscriber::fmt::format::test: [0-9]+: hello\n$")
- .unwrap();
- let _default = set_default(&subscriber.into());
- tracing::info!("hello");
- let res = make_writer.get_string();
- assert!(expected.is_match(&res));
- }
-
- #[test]
- fn with_filename() {
- let make_writer = MockMakeWriter::default();
- let subscriber = crate::fmt::Subscriber::builder()
- .with_writer(make_writer.clone())
- .with_file(true)
- .with_level(false)
- .with_ansi(false)
- .with_timer(MockTime);
- let expected = &format!(
- "fake time tracing_subscriber::fmt::format::test: {}: hello\n",
- current_path(),
- );
- assert_info_hello(subscriber, make_writer, expected);
- }
-
- #[test]
- fn with_thread_ids() {
- let make_writer = MockMakeWriter::default();
- let subscriber = crate::fmt::Subscriber::builder()
- .with_writer(make_writer.clone())
- .with_thread_ids(true)
- .with_ansi(false)
- .with_timer(MockTime);
- let expected =
- "fake time INFO ThreadId(NUMERIC) tracing_subscriber::fmt::format::test: hello\n";
-
- assert_info_hello_ignore_numeric(subscriber, make_writer, expected);
- }
-
- #[test]
- fn pretty_default() {
- let make_writer = MockMakeWriter::default();
- let subscriber = crate::fmt::Subscriber::builder()
- .pretty()
- .with_writer(make_writer.clone())
- .with_ansi(false)
- .with_timer(MockTime);
- let expected = format!(
- r#" fake time INFO tracing_subscriber::fmt::format::test: hello
- at {}:NUMERIC
-
-"#,
- file!()
- );
-
- assert_info_hello_ignore_numeric(subscriber, make_writer, &expected)
- }
-
- fn assert_info_hello(subscriber: impl Into<Dispatch>, buf: MockMakeWriter, expected: &str) {
- let _default = set_default(&subscriber.into());
- tracing::info!("hello");
- let result = buf.get_string();
-
- assert_eq!(expected, result)
- }
-
- // When numeric characters are used they often form a non-deterministic value as they usually represent things like a thread id or line number.
- // This assert method should be used when non-deterministic numeric characters are present.
- fn assert_info_hello_ignore_numeric(
- subscriber: impl Into<Dispatch>,
- buf: MockMakeWriter,
- expected: &str,
- ) {
- let _default = set_default(&subscriber.into());
- tracing::info!("hello");
-
- let regex = Regex::new("[0-9]+").unwrap();
- let result = buf.get_string();
- let result_cleaned = regex.replace_all(&result, "NUMERIC");
-
- assert_eq!(expected, result_cleaned)
- }
-
fn test_overridden_parents<T>(
expected: &str,
builder: crate::fmt::SubscriberBuilder<DefaultFields, Format<T>>,
@@ -1922,14 +1606,14 @@ pub(super) mod test {
T: Send + Sync + 'static,
{
let make_writer = MockMakeWriter::default();
- let subscriber = builder
+ let collector = builder
.with_writer(make_writer.clone())
.with_level(false)
.with_ansi(false)
.with_timer(MockTime)
.finish();
- with_default(subscriber, || {
+ with_default(collector, || {
let span1 = tracing::info_span!("span1", span = 1);
let span2 = tracing::info_span!(parent: &span1, "span2", span = 2);
tracing::info!(parent: &span2, "hello");
@@ -1975,21 +1659,6 @@ pub(super) mod test {
mod default {
use super::*;
-
- #[test]
- fn with_thread_ids() {
- let make_writer = MockMakeWriter::default();
- let subscriber = crate::fmt::Subscriber::builder()
- .with_writer(make_writer.clone())
- .with_thread_ids(true)
- .with_ansi(false)
- .with_timer(MockTime);
- let expected =
- "fake time INFO ThreadId(NUMERIC) tracing_subscriber::fmt::format::test: hello\n";
-
- assert_info_hello_ignore_numeric(subscriber, make_writer, expected);
- }
-
#[cfg(feature = "ansi")]
#[test]
fn with_ansi_true() {
@@ -2079,26 +1748,6 @@ pub(super) mod test {
}
}
- mod pretty {
- use super::*;
-
- #[test]
- fn pretty_default() {
- let make_writer = MockMakeWriter::default();
- let subscriber = crate::fmt::Subscriber::builder()
- .pretty()
- .with_writer(make_writer.clone())
- .with_ansi(false)
- .with_timer(MockTime);
- let expected = format!(
- " fake time INFO tracing_subscriber::fmt::format::test: hello\n at {}:NUMERIC\n\n",
- file!()
- );
-
- assert_info_hello_ignore_numeric(subscriber, make_writer, &expected)
- }
- }
-
#[test]
fn format_nanos() {
fn fmt(t: u64) -> String {
@@ -2146,16 +1795,4 @@ pub(super) mod test {
assert!(!f.contains(FmtSpan::EXIT));
assert!(f.contains(FmtSpan::CLOSE));
}
-
- /// Returns the test's module path.
- fn current_path() -> String {
- Path::new("tracing-subscriber")
- .join("src")
- .join("fmt")
- .join("format")
- .join("mod.rs")
- .to_str()
- .expect("path must not contain invalid unicode")
- .to_owned()
- }
}
diff --git a/vendor/tracing-subscriber/src/fmt/format/pretty.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/format/pretty.rs
index a50d08ba7..3e47e2d93 100644
--- a/vendor/tracing-subscriber/src/fmt/format/pretty.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/format/pretty.rs
@@ -17,84 +17,6 @@ use tracing_log::NormalizeEvent;
use ansi_term::{Colour, Style};
/// An excessively pretty, human-readable event formatter.
-///
-/// Unlike the [`Full`], [`Compact`], and [`Json`] formatters, this is a
-/// multi-line output format. Each individual event may output multiple lines of
-/// text.
-///
-/// # Example Output
-///
-/// <pre><font color="#4E9A06"><b>:;</b></font> <font color="#4E9A06">cargo</font> run --example fmt-pretty
-/// <font color="#4E9A06"><b> Finished</b></font> dev [unoptimized + debuginfo] target(s) in 0.08s
-/// <font color="#4E9A06"><b> Running</b></font> `target/debug/examples/fmt-pretty`
-/// 2022-02-15T18:44:24.535324Z <font color="#4E9A06"> INFO</font> <font color="#4E9A06"><b>fmt_pretty</b></font><font color="#4E9A06">: preparing to shave yaks, </font><font color="#4E9A06"><b>number_of_yaks</b></font><font color="#4E9A06">: 3</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt-pretty.rs:16 <font color="#AAAAAA"><i>on</i></font> main
-///
-/// 2022-02-15T18:44:24.535403Z <font color="#4E9A06"> INFO</font> <font color="#4E9A06"><b>fmt_pretty::yak_shave</b></font><font color="#4E9A06">: shaving yaks</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:41 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535442Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: hello! I&apos;m gonna shave a yak, </font><font color="#75507B"><b>excitement</b></font><font color="#75507B">: &quot;yay!&quot;</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:16 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 1
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535469Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: yak shaved successfully</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:25 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 1
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535502Z <font color="#3465A4">DEBUG</font> <font color="#3465A4"><b>yak_events</b></font><font color="#3465A4">: </font><font color="#3465A4"><b>yak</b></font><font color="#3465A4">: 1, </font><font color="#3465A4"><b>shaved</b></font><font color="#3465A4">: true</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:46 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535524Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: </font><font color="#75507B"><b>yaks_shaved</b></font><font color="#75507B">: 1</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:55 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535551Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: hello! I&apos;m gonna shave a yak, </font><font color="#75507B"><b>excitement</b></font><font color="#75507B">: &quot;yay!&quot;</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:16 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 2
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535573Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: yak shaved successfully</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:25 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 2
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535600Z <font color="#3465A4">DEBUG</font> <font color="#3465A4"><b>yak_events</b></font><font color="#3465A4">: </font><font color="#3465A4"><b>yak</b></font><font color="#3465A4">: 2, </font><font color="#3465A4"><b>shaved</b></font><font color="#3465A4">: true</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:46 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535618Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: </font><font color="#75507B"><b>yaks_shaved</b></font><font color="#75507B">: 2</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:55 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535644Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: hello! I&apos;m gonna shave a yak, </font><font color="#75507B"><b>excitement</b></font><font color="#75507B">: &quot;yay!&quot;</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:16 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 3
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535670Z <font color="#C4A000"> WARN</font> <font color="#C4A000"><b>fmt_pretty::yak_shave</b></font><font color="#C4A000">: could not locate yak</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:18 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 3
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535698Z <font color="#3465A4">DEBUG</font> <font color="#3465A4"><b>yak_events</b></font><font color="#3465A4">: </font><font color="#3465A4"><b>yak</b></font><font color="#3465A4">: 3, </font><font color="#3465A4"><b>shaved</b></font><font color="#3465A4">: false</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:46 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535720Z <font color="#CC0000">ERROR</font> <font color="#CC0000"><b>fmt_pretty::yak_shave</b></font><font color="#CC0000">: failed to shave yak, </font><font color="#CC0000"><b>yak</b></font><font color="#CC0000">: 3, </font><font color="#CC0000"><b>error</b></font><font color="#CC0000">: missing yak, </font><font color="#CC0000"><b>error.sources</b></font><font color="#CC0000">: [out of space, out of cash]</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:51 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535742Z <font color="#75507B">TRACE</font> <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: </font><font color="#75507B"><b>yaks_shaved</b></font><font color="#75507B">: 2</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:55 <font color="#AAAAAA"><i>on</i></font> main
-/// <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
-///
-/// 2022-02-15T18:44:24.535765Z <font color="#4E9A06"> INFO</font> <font color="#4E9A06"><b>fmt_pretty</b></font><font color="#4E9A06">: yak shaving completed, </font><font color="#4E9A06"><b>all_yaks_shaved</b></font><font color="#4E9A06">: false</font>
-/// <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt-pretty.rs:19 <font color="#AAAAAA"><i>on</i></font> main
-/// </pre>
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Pretty {
display_location: bool,
@@ -154,10 +76,6 @@ impl Pretty {
/// Sets whether the event's source code location is displayed.
///
/// This defaults to `true`.
- #[deprecated(
- since = "0.3.6",
- note = "all formatters now support configurable source locations. Use `Format::with_source_location` instead."
- )]
pub fn with_source_location(self, display_location: bool) -> Self {
Self {
display_location,
@@ -166,6 +84,17 @@ impl Pretty {
}
}
+impl<T> Format<Pretty, T> {
+ /// Sets whether or not the source code location from which an event
+ /// originated is displayed.
+ ///
+ /// This defaults to `true`.
+ pub fn with_source_location(mut self, display_location: bool) -> Self {
+ self.format = self.format.with_source_location(display_location);
+ self
+ }
+}
+
impl<C, N, T> FormatEvent<C, N> for Format<Pretty, T>
where
C: Subscriber + for<'a> LookupSpan<'a>,
@@ -218,37 +147,12 @@ where
};
write!(
writer,
- "{}{}{}:",
+ "{}{}{}: ",
target_style.prefix(),
meta.target(),
target_style.infix(style)
)?;
}
- let line_number = if self.display_line_number {
- meta.line()
- } else {
- None
- };
-
- // If the file name is disabled, format the line number right after the
- // target. Otherwise, if we also display the file, it'll go on a
- // separate line.
- if let (Some(line_number), false, true) = (
- line_number,
- self.display_filename,
- self.format.display_location,
- ) {
- write!(
- writer,
- "{}{}{}:",
- style.prefix(),
- line_number,
- style.infix(style)
- )?;
- }
-
- writer.write_char(' ')?;
-
let mut v = PrettyVisitor::new(writer.by_ref(), true).with_style(style);
event.record(&mut v);
v.finish()?;
@@ -260,21 +164,20 @@ where
Style::new()
};
let thread = self.display_thread_name || self.display_thread_id;
-
- if let (Some(file), true, true) = (
- meta.file(),
- self.format.display_location,
- self.display_filename,
- ) {
- write!(writer, " {} {}", dimmed.paint("at"), file,)?;
-
- if let Some(line) = line_number {
- write!(writer, ":{}", line)?;
- }
- writer.write_char(if thread { ' ' } else { '\n' })?;
+ if let (true, Some(file), Some(line)) =
+ (self.format.display_location, meta.file(), meta.line())
+ {
+ write!(
+ writer,
+ " {} {}:{}{}",
+ dimmed.paint("at"),
+ file,
+ line,
+ dimmed.paint(if thread { " " } else { "\n" })
+ )?;
} else if thread {
write!(writer, " ")?;
- };
+ }
if thread {
write!(writer, "{} ", dimmed.paint("on"))?;
@@ -283,12 +186,13 @@ where
if let Some(name) = thread.name() {
write!(writer, "{}", name)?;
if self.display_thread_id {
- writer.write_char(' ')?;
+ write!(writer, " ({:?})", thread.id())?;
}
+ } else if !self.display_thread_id {
+ write!(writer, " {:?}", thread.id())?;
}
- }
- if self.display_thread_id {
- write!(writer, "{:?}", thread.id())?;
+ } else if self.display_thread_id {
+ write!(writer, " {:?}", thread.id())?;
}
writer.write_char('\n')?;
}
@@ -336,7 +240,7 @@ where
impl<'writer> FormatFields<'writer> for Pretty {
fn format_fields<R: RecordFields>(&self, writer: Writer<'writer>, fields: R) -> fmt::Result {
- let mut v = PrettyVisitor::new(writer, true);
+ let mut v = PrettyVisitor::new(writer, false);
fields.record(&mut v);
v.finish()
}
diff --git a/vendor/tracing-subscriber/src/fmt/mod.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/mod.rs
index 3c6a6ac40..d5deb8f0c 100644
--- a/vendor/tracing-subscriber/src/fmt/mod.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/mod.rs
@@ -13,12 +13,10 @@
//!
//! ```toml
//! [dependencies]
-//! tracing-subscriber = "0.3"
+//! tracing-subscriber = "0.2"
//! ```
//!
-//! *Compiler support: [requires `rustc` 1.49+][msrv]*
-//!
-//! [msrv]: super#supported-rust-versions
+//! *Compiler support: requires rustc 1.39+*
//!
//! Add the following to your executable to initialize the default subscriber:
//! ```rust
@@ -70,25 +68,132 @@
//!
//! * [`format::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](format::Full#example-output) for sample output.
+//! displayed before the formatted representation of the event.
//!
-//! * [`format::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. See
-//! [here](format::Compact#example-output) for sample output.
+//! For example:
+//! <pre><font color="#4E9A06"><b> Finished</b></font> dev [unoptimized + debuginfo] target(s) in 1.59s
+//! <font color="#4E9A06"><b> Running</b></font> `target/debug/examples/fmt`
+//! <font color="#AAAAAA">Oct 24 12:55:47.814 </font><font color="#4E9A06"> INFO</font> fmt: preparing to shave yaks number_of_yaks=3
+//! <font color="#AAAAAA">Oct 24 12:55:47.814 </font><font color="#4E9A06"> INFO</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: fmt::yak_shave: shaving yaks
+//! <font color="#AAAAAA">Oct 24 12:55:47.814 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>:<b>shave{</b>yak=1<b>}</b>: fmt::yak_shave: hello! I&apos;m gonna shave a yak excitement=&quot;yay!&quot;
+//! <font color="#AAAAAA">Oct 24 12:55:47.814 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>:<b>shave{</b>yak=1<b>}</b>: fmt::yak_shave: yak shaved successfully
+//! <font color="#AAAAAA">Oct 24 12:55:47.814 </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: yak_events: yak=1 shaved=true
+//! <font color="#AAAAAA">Oct 24 12:55:47.814 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: fmt::yak_shave: yaks_shaved=1
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>:<b>shave{</b>yak=2<b>}</b>: fmt::yak_shave: hello! I&apos;m gonna shave a yak excitement=&quot;yay!&quot;
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>:<b>shave{</b>yak=2<b>}</b>: fmt::yak_shave: yak shaved successfully
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: yak_events: yak=2 shaved=true
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: fmt::yak_shave: yaks_shaved=2
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>:<b>shave{</b>yak=3<b>}</b>: fmt::yak_shave: hello! I&apos;m gonna shave a yak excitement=&quot;yay!&quot;
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#C4A000"> WARN</font> <b>shaving_yaks{</b>yaks=3<b>}</b>:<b>shave{</b>yak=3<b>}</b>: fmt::yak_shave: could not locate yak
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#3465A4">DEBUG</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: yak_events: yak=3 shaved=false
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#CC0000">ERROR</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: fmt::yak_shave: failed to shave yak yak=3 error=missing yak
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#75507B">TRACE</font> <b>shaving_yaks{</b>yaks=3<b>}</b>: fmt::yak_shave: yaks_shaved=2
+//! <font color="#AAAAAA">Oct 24 12:55:47.815 </font><font color="#4E9A06"> INFO</font> fmt: yak shaving completed all_yaks_shaved=false
+//! </pre>
//!
//! * [`format::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](format::Pretty#example-output)
-//! for sample output.
+//! readability and visual appeal.
+//!
+//! For example:
+//! <pre><font color="#4E9A06"><b> Finished</b></font> dev [unoptimized + debuginfo] target(s) in 1.61s
+//! <font color="#4E9A06"><b> Running</b></font> `target/debug/examples/fmt-pretty`
+//! Oct 24 12:57:29.386 <font color="#4E9A06"><b>fmt_pretty</b></font><font color="#4E9A06">: preparing to shave yaks, </font><font color="#4E9A06"><b>number_of_yaks</b></font><font color="#4E9A06">: 3</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt-pretty.rs:16<font color="#AAAAAA"><i> on</i></font> main
+//!
+//! Oct 24 12:57:29.386 <font color="#4E9A06"><b>fmt_pretty::yak_shave</b></font><font color="#4E9A06">: shaving yaks</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:38<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: hello! I&apos;m gonna shave a yak, </font><font color="#75507B"><b>excitement</b></font><font color="#75507B">: &quot;yay!&quot;</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:14<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 1
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: yak shaved successfully</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:22<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 1
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#3465A4"><b>yak_events</b></font><font color="#3465A4">: </font><font color="#3465A4"><b>yak</b></font><font color="#3465A4">: 1, </font><font color="#3465A4"><b>shaved</b></font><font color="#3465A4">: true</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:43<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: </font><font color="#75507B"><b>yaks_shaved</b></font><font color="#75507B">: 1</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:52<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: hello! I&apos;m gonna shave a yak, </font><font color="#75507B"><b>excitement</b></font><font color="#75507B">: &quot;yay!&quot;</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:14<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 2
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: yak shaved successfully</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:22<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 2
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#3465A4"><b>yak_events</b></font><font color="#3465A4">: </font><font color="#3465A4"><b>yak</b></font><font color="#3465A4">: 2, </font><font color="#3465A4"><b>shaved</b></font><font color="#3465A4">: true</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:43<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: </font><font color="#75507B"><b>yaks_shaved</b></font><font color="#75507B">: 2</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:52<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: hello! I&apos;m gonna shave a yak, </font><font color="#75507B"><b>excitement</b></font><font color="#75507B">: &quot;yay!&quot;</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:14<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 3
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#C4A000"><b>fmt_pretty::yak_shave</b></font><font color="#C4A000">: could not locate yak</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:16<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shave</b> <font color="#AAAAAA"><i>with</i></font> <b>yak</b>: 3
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#3465A4"><b>yak_events</b></font><font color="#3465A4">: </font><font color="#3465A4"><b>yak</b></font><font color="#3465A4">: 3, </font><font color="#3465A4"><b>shaved</b></font><font color="#3465A4">: false</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:43<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#CC0000"><b>fmt_pretty::yak_shave</b></font><font color="#CC0000">: failed to shave yak, </font><font color="#CC0000"><b>yak</b></font><font color="#CC0000">: 3, </font><font color="#CC0000"><b>error</b></font><font color="#CC0000">: missing yak</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:48<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#75507B"><b>fmt_pretty::yak_shave</b></font><font color="#75507B">: </font><font color="#75507B"><b>yaks_shaved</b></font><font color="#75507B">: 2</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt/yak_shave.rs:52<font color="#AAAAAA"><i> on</i></font> main
+//! <font color="#AAAAAA"><i>in</i></font> fmt_pretty::yak_shave::<b>shaving_yaks</b> <font color="#AAAAAA"><i>with</i></font> <b>yaks</b>: 3
+//!
+//! Oct 24 12:57:29.387 <font color="#4E9A06"><b>fmt_pretty</b></font><font color="#4E9A06">: yak shaving completed, </font><font color="#4E9A06"><b>all_yaks_shaved</b></font><font color="#4E9A06">: false</font>
+//! <font color="#AAAAAA"><i>at</i></font> examples/examples/fmt-pretty.rs:19<font color="#AAAAAA"><i> on</i></font> main
+//! </pre>
//!
//! * [`format::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](format::Json#example-output) for sample output.
+//! by analysis and viewing tools. The JSON output, as seen below, is *not*
+//! optimized for human readability.
+//!
+//! For example:
+//! <pre><font color="#4E9A06"><b> Finished</b></font> dev [unoptimized + debuginfo] target(s) in 1.58s
+//! <font color="#4E9A06"><b> Running</b></font> `target/debug/examples/fmt-json`
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.873&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;preparing to shave yaks&quot;,&quot;number_of_yaks&quot;:3},&quot;target&quot;:&quot;fmt_json&quot;}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;shaving yaks&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;hello! I&apos;m gonna shave a yak&quot;,&quot;excitement&quot;:&quot;yay!&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:&quot;1&quot;,&quot;name&quot;:&quot;shave&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;yak shaved successfully&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:&quot;1&quot;,&quot;name&quot;:&quot;shave&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;DEBUG&quot;,&quot;fields&quot;:{&quot;yak&quot;:1,&quot;shaved&quot;:true},&quot;target&quot;:&quot;yak_events&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;yaks_shaved&quot;:1},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;hello! I&apos;m gonna shave a yak&quot;,&quot;excitement&quot;:&quot;yay!&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:&quot;2&quot;,&quot;name&quot;:&quot;shave&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;yak shaved successfully&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:&quot;2&quot;,&quot;name&quot;:&quot;shave&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;DEBUG&quot;,&quot;fields&quot;:{&quot;yak&quot;:2,&quot;shaved&quot;:true},&quot;target&quot;:&quot;yak_events&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;yaks_shaved&quot;:2},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.874&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;hello! I&apos;m gonna shave a yak&quot;,&quot;excitement&quot;:&quot;yay!&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:&quot;3&quot;,&quot;name&quot;:&quot;shave&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.875&quot;,&quot;level&quot;:&quot;WARN&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;could not locate yak&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;},{&quot;yak&quot;:&quot;3&quot;,&quot;name&quot;:&quot;shave&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.875&quot;,&quot;level&quot;:&quot;DEBUG&quot;,&quot;fields&quot;:{&quot;yak&quot;:3,&quot;shaved&quot;:false},&quot;target&quot;:&quot;yak_events&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.875&quot;,&quot;level&quot;:&quot;ERROR&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;failed to shave yak&quot;,&quot;yak&quot;:3,&quot;error&quot;:&quot;missing yak&quot;},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.875&quot;,&quot;level&quot;:&quot;TRACE&quot;,&quot;fields&quot;:{&quot;yaks_shaved&quot;:2},&quot;target&quot;:&quot;fmt_json::yak_shave&quot;,&quot;spans&quot;:[{&quot;yaks&quot;:3,&quot;name&quot;:&quot;shaving_yaks&quot;}]}
+//! {&quot;timestamp&quot;:&quot;Oct 24 13:00:00.875&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;fields&quot;:{&quot;message&quot;:&quot;yak shaving completed&quot;,&quot;all_yaks_shaved&quot;:false},&quot;target&quot;:&quot;fmt_json&quot;}
+//! </pre>
//!
//! ### Customizing Formatters
//!
@@ -116,7 +221,7 @@
//! .with_thread_names(true) // include the name of the current thread
//! .compact(); // use the `Compact` formatting style.
//!
-//! // Create a `fmt` subscriber that uses our custom event format, and set it
+//! // Create a `fmt` collector that uses our custom event format, and set it
//! // as the default.
//! tracing_subscriber::fmt()
//! .event_format(format)
@@ -163,7 +268,7 @@
//!
//! ### Composing Layers
//!
-//! Composing an [`EnvFilter`] `Layer` and a [format `Layer`][super::fmt::Layer]:
+//! Composing an [`EnvFilter`] `Layer` and a [format `Layer`](../fmt/struct.Layer.html):
//!
//! ```rust
//! use tracing_subscriber::{fmt, EnvFilter};
@@ -181,10 +286,11 @@
//! .init();
//! ```
//!
-//! [`EnvFilter`]: super::filter::EnvFilter
+//! [`EnvFilter`]: ../filter/struct.EnvFilter.html
//! [`env_logger`]: https://docs.rs/env_logger/
-//! [`filter`]: super::filter
-//! [`FmtSubscriber`]: Subscriber
+//! [`filter`]: ../filter/index.html
+//! [`SubscriberBuilder`]: ./struct.SubscriberBuilder.html
+//! [`FmtSubscriber`]: ./struct.Subscriber.html
//! [`Subscriber`]:
//! https://docs.rs/tracing/latest/tracing/trait.Subscriber.html
//! [`tracing`]: https://crates.io/crates/tracing
@@ -203,7 +309,6 @@ pub mod writer;
pub use fmt_layer::{FmtContext, FormattedFields, Layer};
use crate::layer::Layer as _;
-use crate::util::SubscriberInitExt;
use crate::{
filter::LevelFilter,
layer,
@@ -312,7 +417,7 @@ pub struct SubscriberBuilder<
/// ```
///
/// [formatting subscriber]: Subscriber
-/// [`SubscriberBuilder::default()`]: SubscriberBuilder::default
+/// [`SubscriberBuilder::default()`]: SubscriberBuilder::default()
/// [`init`]: SubscriberBuilder::init()
/// [`try_init`]: SubscriberBuilder::try_init()
/// [`finish`]: SubscriberBuilder::finish()
@@ -324,11 +429,10 @@ pub fn fmt() -> SubscriberBuilder {
/// Returns a new [formatting layer] that can be [composed] with other layers to
/// construct a [`Subscriber`].
///
-/// This is a shorthand for the equivalent [`Layer::default()`] function.
+/// This is a shorthand for the equivalent [`Layer::default`] function.
///
/// [formatting layer]: Layer
/// [composed]: crate::layer
-/// [`Layer::default()`]: Layer::default
#[cfg_attr(docsrs, doc(cfg(all(feature = "fmt", feature = "std"))))]
pub fn layer<S>() -> Layer<S> {
Layer::default()
@@ -340,8 +444,8 @@ impl Subscriber {
///
/// This can be overridden with the [`SubscriberBuilder::with_max_level`] method.
///
- /// [verbosity level]: tracing_core::Level
- /// [`SubscriberBuilder::with_max_level`]: SubscriberBuilder::with_max_level
+ /// [verbosity level]: https://docs.rs/tracing-core/0.1.5/tracing_core/struct.Level.html
+ /// [`SubscriberBuilder::with_max_level`]: struct.SubscriberBuilder.html#method.with_max_level
pub const DEFAULT_MAX_LEVEL: LevelFilter = LevelFilter::INFO;
/// Returns a new `SubscriberBuilder` for configuring a format subscriber.
@@ -398,11 +502,6 @@ where
}
#[inline]
- fn event_enabled(&self, event: &Event<'_>) -> bool {
- self.inner.event_enabled(event)
- }
-
- #[inline]
fn event(&self, event: &Event<'_>) {
self.inner.event(event);
}
@@ -602,7 +701,7 @@ where
/// `Layer`s added to this subscriber.
///
/// [lifecycle]: https://docs.rs/tracing/latest/tracing/span/index.html#the-span-lifecycle
- /// [time]: SubscriberBuilder::without_time()
+ /// [time]: #method.without_time
pub fn with_span_events(self, kind: format::FmtSpan) -> Self {
SubscriberBuilder {
inner: self.inner.with_span_events(kind),
@@ -631,34 +730,6 @@ where
}
}
- /// Sets whether or not an event's [source code file path][file] is
- /// displayed.
- ///
- /// [file]: tracing_core::Metadata::file
- pub fn with_file(
- self,
- display_filename: bool,
- ) -> SubscriberBuilder<N, format::Format<L, T>, F, W> {
- SubscriberBuilder {
- inner: self.inner.with_file(display_filename),
- ..self
- }
- }
-
- /// Sets whether or not an event's [source code line number][line] is
- /// displayed.
- ///
- /// [line]: tracing_core::Metadata::line
- pub fn with_line_number(
- self,
- display_line_number: bool,
- ) -> SubscriberBuilder<N, format::Format<L, T>, F, W> {
- SubscriberBuilder {
- inner: self.inner.with_line_number(display_line_number),
- ..self
- }
- }
-
/// Sets whether or not an event's level is displayed.
pub fn with_level(
self,
@@ -671,9 +742,9 @@ where
}
/// Sets whether or not the [name] of the current thread is displayed
- /// when formatting events.
+ /// when formatting events
///
- /// [name]: std::thread#naming-threads
+ /// [name]: https://doc.rust-lang.org/stable/std/thread/index.html#naming-threads
pub fn with_thread_names(
self,
display_thread_names: bool,
@@ -685,9 +756,9 @@ where
}
/// Sets whether or not the [thread ID] of the current thread is displayed
- /// when formatting events.
+ /// when formatting events
///
- /// [thread ID]: std::thread::ThreadId
+ /// [thread ID]: https://doc.rust-lang.org/stable/std/thread/struct.ThreadId.html
pub fn with_thread_ids(
self,
display_thread_ids: bool,
@@ -725,7 +796,7 @@ where
/// Sets the subscriber being built to use a JSON formatter.
///
- /// See [`format::Json`][super::fmt::format::Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn json(
@@ -746,7 +817,7 @@ where
impl<T, F, W> SubscriberBuilder<format::JsonFields, format::Format<format::Json, T>, F, W> {
/// Sets the json subscriber being built to flatten event metadata.
///
- /// See [`format::Json`][super::fmt::format::Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
pub fn flatten_event(
self,
flatten_event: bool,
@@ -760,7 +831,7 @@ impl<T, F, W> SubscriberBuilder<format::JsonFields, format::Format<format::Json,
/// Sets whether or not the JSON subscriber being built will include the current span
/// in formatted events.
///
- /// See [`format::Json`][super::fmt::format::Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
pub fn with_current_span(
self,
display_current_span: bool,
@@ -774,7 +845,7 @@ impl<T, F, W> SubscriberBuilder<format::JsonFields, format::Format<format::Json,
/// Sets whether or not the JSON subscriber being built will include a list (from
/// root to leaf) of all currently entered spans in formatted events.
///
- /// See [`format::Json`][super::fmt::format::Json]
+ /// See [`format::Json`](../fmt/format/struct.Json.html)
pub fn with_span_list(
self,
display_span_list: bool,
@@ -820,7 +891,7 @@ where
}
impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
- /// Sets the field formatter that the subscriber being built will use to record
+ /// Sets the Visitor that the subscriber being built will use to record
/// fields.
///
/// For example:
@@ -896,8 +967,8 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
/// .try_init()?;
/// # Ok(())}
/// ```
- /// [`EnvFilter`]: super::filter::EnvFilter
- /// [`with_max_level`]: SubscriberBuilder::with_max_level()
+ /// [`EnvFilter`]: ../filter/struct.EnvFilter.html
+ /// [`with_max_level`]: #method.with_max_level
#[cfg(feature = "env-filter")]
#[cfg_attr(docsrs, doc(cfg(feature = "env-filter")))]
pub fn with_env_filter(
@@ -918,7 +989,7 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
/// subscriber.
///
/// If the max level has already been set, or a [`EnvFilter`] was added by
- /// [`with_env_filter`], this replaces that configuration with the new
+ /// [`with_filter`], this replaces that configuration with the new
/// maximum level.
///
/// # Examples
@@ -940,9 +1011,9 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
/// .with_max_level(LevelFilter::OFF)
/// .finish();
/// ```
- /// [verbosity level]: tracing_core::Level
- /// [`EnvFilter`]: struct@crate::filter::EnvFilter
- /// [`with_env_filter`]: fn@Self::with_env_filter
+ /// [verbosity level]: https://docs.rs/tracing-core/0.1.5/tracing_core/struct.Level.html
+ /// [`EnvFilter`]: ../filter/struct.EnvFilter.html
+ /// [`with_filter`]: #method.with_filter
pub fn with_max_level(
self,
filter: impl Into<LevelFilter>,
@@ -954,26 +1025,8 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
}
}
- /// Sets the [event formatter][`FormatEvent`] that the subscriber being built
- /// will use to format events that occur.
- ///
- /// The event formatter may be any type implementing the [`FormatEvent`]
- /// trait, which is implemented for all functions taking a [`FmtContext`], a
- /// [`Writer`], and an [`Event`].
- ///
- /// # Examples
- ///
- /// Setting a type implementing [`FormatEvent`] as the formatter:
- ///
- /// ```rust
- /// use tracing_subscriber::fmt::format;
- ///
- /// let subscriber = tracing_subscriber::fmt()
- /// .event_format(format().compact())
- /// .finish();
- /// ```
- ///
- /// [`Writer`]: struct@self::format::Writer
+ /// Sets the function that the subscriber being built should use to format
+ /// events that occur.
pub fn event_format<E2>(self, fmt_event: E2) -> SubscriberBuilder<N, E2, F, W>
where
E2: FormatEvent<Registry, N> + 'static,
@@ -1000,6 +1053,8 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
/// .with_writer(io::stderr)
/// .init();
/// ```
+ ///
+ /// [`MakeWriter`]: trait.MakeWriter.html
pub fn with_writer<W2>(self, make_writer: W2) -> SubscriberBuilder<N, E, F, W2>
where
W2: for<'writer> MakeWriter<'writer> + 'static,
@@ -1033,89 +1088,13 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
///
/// [capturing]:
/// https://doc.rust-lang.org/book/ch11-02-running-tests.html#showing-function-output
- /// [`TestWriter`]: writer::TestWriter
+ /// [`TestWriter`]: writer/struct.TestWriter.html
pub fn with_test_writer(self) -> SubscriberBuilder<N, E, F, TestWriter> {
SubscriberBuilder {
filter: self.filter,
inner: self.inner.with_writer(TestWriter::default()),
}
}
-
- /// Updates the event formatter by applying a function to the existing event formatter.
- ///
- /// This sets the event formatter that the subscriber being built will use to record fields.
- ///
- /// # Examples
- ///
- /// Updating an event formatter:
- ///
- /// ```rust
- /// let subscriber = tracing_subscriber::fmt()
- /// .map_event_format(|e| e.compact())
- /// .finish();
- /// ```
- pub fn map_event_format<E2>(self, f: impl FnOnce(E) -> E2) -> SubscriberBuilder<N, E2, F, W>
- where
- E2: FormatEvent<Registry, N> + 'static,
- N: for<'writer> FormatFields<'writer> + 'static,
- W: for<'writer> MakeWriter<'writer> + 'static,
- {
- SubscriberBuilder {
- filter: self.filter,
- inner: self.inner.map_event_format(f),
- }
- }
-
- /// Updates the field formatter by applying a function to the existing field formatter.
- ///
- /// This sets the field formatter that the subscriber being built will use to record fields.
- ///
- /// # Examples
- ///
- /// Updating a field formatter:
- ///
- /// ```rust
- /// use tracing_subscriber::field::MakeExt;
- /// let subscriber = tracing_subscriber::fmt()
- /// .map_fmt_fields(|f| f.debug_alt())
- /// .finish();
- /// ```
- pub fn map_fmt_fields<N2>(self, f: impl FnOnce(N) -> N2) -> SubscriberBuilder<N2, E, F, W>
- where
- N2: for<'writer> FormatFields<'writer> + 'static,
- {
- SubscriberBuilder {
- filter: self.filter,
- inner: self.inner.map_fmt_fields(f),
- }
- }
-
- /// Updates the [`MakeWriter`] by applying a function to the existing [`MakeWriter`].
- ///
- /// This sets the [`MakeWriter`] that the subscriber being built will use to write events.
- ///
- /// # Examples
- ///
- /// Redirect output to stderr if level is <= WARN:
- ///
- /// ```rust
- /// use tracing::Level;
- /// use tracing_subscriber::fmt::{self, writer::MakeWriterExt};
- ///
- /// let stderr = std::io::stderr.with_max_level(Level::WARN);
- /// let layer = tracing_subscriber::fmt()
- /// .map_writer(move |w| stderr.or_else(w))
- /// .finish();
- /// ```
- pub fn map_writer<W2>(self, f: impl FnOnce(W) -> W2) -> SubscriberBuilder<N, E, F, W2>
- where
- W2: for<'writer> MakeWriter<'writer> + 'static,
- {
- SubscriberBuilder {
- filter: self.filter,
- inner: self.inner.map_writer(f),
- }
- }
}
/// Install a global tracing subscriber that listens for events and
@@ -1142,44 +1121,15 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
///
/// [`LogTracer`]:
/// https://docs.rs/tracing-log/0.1.0/tracing_log/struct.LogTracer.html
-/// [`RUST_LOG` environment variable]: crate::filter::EnvFilter::DEFAULT_ENV
+/// [`RUST_LOG` environment variable]:
+/// ../filter/struct.EnvFilter.html#associatedconstant.DEFAULT_ENV
pub fn try_init() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let builder = Subscriber::builder();
#[cfg(feature = "env-filter")]
let builder = builder.with_env_filter(crate::EnvFilter::from_default_env());
- // If `env-filter` is disabled, remove the default max level filter from the
- // subscriber; it will be added to the `Targets` filter instead if no filter
- // is set in `RUST_LOG`.
- // Replacing the default `LevelFilter` with an `EnvFilter` would imply this,
- // but we can't replace the builder's filter with a `Targets` filter yet.
- #[cfg(not(feature = "env-filter"))]
- let builder = builder.with_max_level(LevelFilter::TRACE);
-
- let subscriber = builder.finish();
- #[cfg(not(feature = "env-filter"))]
- let subscriber = {
- use crate::{filter::Targets, layer::SubscriberExt};
- use std::{env, str::FromStr};
- let targets = match env::var("RUST_LOG") {
- Ok(var) => Targets::from_str(&var)
- .map_err(|e| {
- eprintln!("Ignoring `RUST_LOG={:?}`: {}", var, e);
- })
- .unwrap_or_default(),
- Err(env::VarError::NotPresent) => {
- Targets::new().with_default(Subscriber::DEFAULT_MAX_LEVEL)
- }
- Err(e) => {
- eprintln!("Ignoring `RUST_LOG`: {}", e);
- Targets::new().with_default(Subscriber::DEFAULT_MAX_LEVEL)
- }
- };
- subscriber.with(targets)
- };
-
- subscriber.try_init().map_err(Into::into)
+ builder.try_init()
}
/// Install a global tracing subscriber that listens for events and
@@ -1198,7 +1148,8 @@ pub fn try_init() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
/// Panics if the initialization was unsuccessful, likely because a
/// global subscriber was already installed by another call to `try_init`.
///
-/// [`RUST_LOG` environment variable]: crate::filter::EnvFilter::DEFAULT_ENV
+/// [`RUST_LOG` environment variable]:
+/// ../filter/struct.EnvFilter.html#associatedconstant.DEFAULT_ENV
pub fn init() {
try_init().expect("Unable to install global subscriber")
}
diff --git a/vendor/tracing-subscriber/src/fmt/time/datetime.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/time/datetime.rs
index 531331687..531331687 100644
--- a/vendor/tracing-subscriber/src/fmt/time/datetime.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/time/datetime.rs
diff --git a/vendor/tracing-subscriber/src/fmt/time/mod.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/time/mod.rs
index e5b7c83b0..621df16e4 100644
--- a/vendor/tracing-subscriber/src/fmt/time/mod.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/time/mod.rs
@@ -12,13 +12,9 @@ mod time_crate;
pub use time_crate::UtcTime;
#[cfg(feature = "local-time")]
-#[cfg_attr(docsrs, doc(cfg(unsound_local_offset, feature = "local-time")))]
+#[cfg_attr(docsrs, doc(cfg(feature = "local-time")))]
pub use time_crate::LocalTime;
-#[cfg(feature = "time")]
-#[cfg_attr(docsrs, doc(cfg(feature = "time")))]
-pub use time_crate::OffsetTime;
-
/// A type that can measure and format the current time.
///
/// This trait is used by `Format` to include a timestamp with each `Event` when it is logged.
@@ -30,7 +26,7 @@ pub use time_crate::OffsetTime;
///
/// The full list of provided implementations can be found in [`time`].
///
-/// [`time`]: self
+/// [`time`]: ./index.html
pub trait FormatTime {
/// Measure and write out the current time.
///
diff --git a/vendor/tracing-subscriber/src/fmt/writer.rs b/vendor/tracing-subscriber-0.3.3/src/fmt/writer.rs
index 4aacd6d54..0974891f7 100644
--- a/vendor/tracing-subscriber/src/fmt/writer.rs
+++ b/vendor/tracing-subscriber-0.3.3/src/fmt/writer.rs
@@ -1,6 +1,6 @@
//! Abstractions for creating [`io::Write`] instances.
//!
-//! [`io::Write`]: std::io::Write
+//! [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
use std::{
fmt,
io::{self, Write},
@@ -96,8 +96,8 @@ use tracing_core::Metadata;
pub trait MakeWriter<'a> {
/// The concrete [`io::Write`] implementation returned by [`make_writer`].
///
- /// [`io::Write`]: std::io::Write
- /// [`make_writer`]: MakeWriter::make_writer
+ /// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
+ /// [`make_writer`]: #tymethod.make_writer
type Writer: io::Write;
/// Returns an instance of [`Writer`].
@@ -109,7 +109,7 @@ pub trait MakeWriter<'a> {
/// creating a [`io::Write`] instance is expensive, be sure to cache it when implementing
/// [`MakeWriter`] to improve performance.
///
- /// [`Writer`]: MakeWriter::Writer
+ /// [`Writer`]: #associatedtype.Writer
/// [`fmt::Layer`]: crate::fmt::Layer
/// [`fmt::Subscriber`]: crate::fmt::Subscriber
/// [`io::Write`]: std::io::Write
@@ -501,13 +501,13 @@ pub trait MakeWriterExt<'a>: MakeWriter<'a> {
/// Writing to [`io::stdout`] and [`io::stderr`] produces the same results as using
/// [`libtest`'s `--nocapture` option][nocapture] which may make the results look unreadable.
///
-/// [`fmt::Subscriber`]: super::Subscriber
-/// [`fmt::Layer`]: super::Layer
+/// [`fmt::Subscriber`]: ../struct.Subscriber.html
+/// [`fmt::Layer`]: ../struct.Layer.html
/// [capturing]: https://doc.rust-lang.org/book/ch11-02-running-tests.html#showing-function-output
/// [nocapture]: https://doc.rust-lang.org/cargo/commands/cargo-test.html
-/// [`io::stdout`]: std::io::stdout
-/// [`io::stderr`]: std::io::stderr
-/// [`print!`]: std::print!
+/// [`io::stdout`]: https://doc.rust-lang.org/std/io/fn.stdout.html
+/// [`io::stderr`]: https://doc.rust-lang.org/std/io/fn.stderr.html
+/// [`print!`]: https://doc.rust-lang.org/std/macro.print.html
#[derive(Default, Debug)]
pub struct TestWriter {
_p: (),
@@ -646,9 +646,10 @@ pub struct Tee<A, B> {
/// requires the `Writer` type to implement [`io::Write`], it's necessary to add
/// a newtype that forwards the trait implementation.
///
-/// [`io::Write`]: std::io::Write
-/// [`MutexGuard`]: std::sync::MutexGuard
-/// [`Mutex`]: std::sync::Mutex
+/// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
+/// [`MutexGuard`]: https://doc.rust-lang.org/std/sync/struct.MutexGuard.html
+/// [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html
+/// [`MakeWriter`]: trait.MakeWriter.html
#[derive(Debug)]
pub struct MutexGuardWriter<'a, W>(MutexGuard<'a, W>);
@@ -733,6 +734,7 @@ impl<'a> MakeWriter<'a> for TestWriter {
impl BoxMakeWriter {
/// Constructs a `BoxMakeWriter` wrapping a type implementing [`MakeWriter`].
///
+ /// [`MakeWriter`]: trait.MakeWriter.html
pub fn new<M>(make_writer: M) -> Self
where
M: for<'a> MakeWriter<'a> + Send + Sync + 'static,
@@ -1023,8 +1025,6 @@ impl<A, B> Tee<A, B> {
/// outputs.
///
/// See the documentation for [`MakeWriterExt::and`] for details.
- ///
- /// [writers]: std::io::Write
pub fn new(a: A, b: B) -> Self {
Self { a, b }
}
diff --git a/vendor/tracing-subscriber/src/fmt/time/time_crate.rs b/vendor/tracing-subscriber/src/fmt/time/time_crate.rs
deleted file mode 100644
index 60d57fd0b..000000000
--- a/vendor/tracing-subscriber/src/fmt/time/time_crate.rs
+++ /dev/null
@@ -1,470 +0,0 @@
-use crate::fmt::{format::Writer, time::FormatTime, writer::WriteAdaptor};
-use std::fmt;
-use time::{format_description::well_known, formatting::Formattable, OffsetDateTime, UtcOffset};
-
-/// Formats the current [local time] using a [formatter] from the [`time` crate].
-///
-/// To format the current [UTC time] instead, use the [`UtcTime`] type.
-///
-/// <div class="example-wrap" style="display:inline-block">
-/// <pre class="compile_fail" style="white-space:normal;font:inherit;">
-/// <strong>Warning</strong>: The <a href = "https://docs.rs/time/0.3/time/"><code>time</code>
-/// crate</a> must be compiled with <code>--cfg unsound_local_offset</code> in order to use
-/// local timestamps. When this cfg is not enabled, local timestamps cannot be recorded, and
-/// events will be logged without timestamps.
-///
-/// Alternatively, [`OffsetTime`] can log with a local offset if it is initialized early.
-///
-/// See the <a href="https://docs.rs/time/0.3.4/time/#feature-flags"><code>time</code>
-/// documentation</a> for more details.
-/// </pre></div>
-///
-/// [local time]: time::OffsetDateTime::now_local
-/// [UTC time]: time::OffsetDateTime::now_utc
-/// [formatter]: time::formatting::Formattable
-/// [`time` crate]: time
-#[derive(Clone, Debug)]
-#[cfg_attr(
- docsrs,
- doc(cfg(all(unsound_local_offset, feature = "time", feature = "local-time")))
-)]
-#[cfg(feature = "local-time")]
-pub struct LocalTime<F> {
- format: F,
-}
-
-/// Formats the current [UTC time] using a [formatter] from the [`time` crate].
-///
-/// To format the current [local time] instead, use the [`LocalTime`] type.
-///
-/// [local time]: time::OffsetDateTime::now_local
-/// [UTC time]: time::OffsetDateTime::now_utc
-/// [formatter]: time::formatting::Formattable
-/// [`time` crate]: time
-#[cfg_attr(docsrs, doc(cfg(feature = "time")))]
-#[derive(Clone, Debug)]
-pub struct UtcTime<F> {
- format: F,
-}
-
-/// Formats the current time using a fixed offset and a [formatter] from the [`time` crate].
-///
-/// This is typically used as an alternative to [`LocalTime`]. `LocalTime` determines the offset
-/// every time it formats a message, which may be unsound or fail. With `OffsetTime`, the offset is
-/// determined once. This makes it possible to do so while the program is still single-threaded and
-/// handle any errors. However, this also means the offset cannot change while the program is
-/// running (the offset will not change across DST changes).
-///
-/// [formatter]: time::formatting::Formattable
-/// [`time` crate]: time
-#[derive(Clone, Debug)]
-#[cfg_attr(docsrs, doc(cfg(feature = "time")))]
-pub struct OffsetTime<F> {
- offset: time::UtcOffset,
- format: F,
-}
-
-// === impl LocalTime ===
-
-#[cfg(feature = "local-time")]
-impl LocalTime<well_known::Rfc3339> {
- /// Returns a formatter that formats the current [local time] in the
- /// [RFC 3339] format (a subset of the [ISO 8601] timestamp format).
- ///
- /// # Examples
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time};
- ///
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(time::LocalTime::rfc_3339());
- /// # drop(collector);
- /// ```
- ///
- /// [local time]: time::OffsetDateTime::now_local
- /// [RFC 3339]: https://datatracker.ietf.org/doc/html/rfc3339
- /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601
- pub fn rfc_3339() -> Self {
- Self::new(well_known::Rfc3339)
- }
-}
-
-#[cfg(feature = "local-time")]
-impl<F: Formattable> LocalTime<F> {
- /// Returns a formatter that formats the current [local time] using the
- /// [`time` crate] with the provided provided format. The format may be any
- /// type that implements the [`Formattable`] trait.
- ///
- ///
- /// <div class="example-wrap" style="display:inline-block">
- /// <pre class="compile_fail" style="white-space:normal;font:inherit;">
- /// <strong>Warning</strong>: The <a href = "https://docs.rs/time/0.3/time/">
- /// <code>time</code> crate</a> must be compiled with <code>--cfg
- /// unsound_local_offset</code> in order to use local timestamps. When this
- /// cfg is not enabled, local timestamps cannot be recorded, and
- /// events will be logged without timestamps.
- ///
- /// See the <a href="https://docs.rs/time/0.3.4/time/#feature-flags">
- /// <code>time</code> documentation</a> for more details.
- /// </pre></div>
- ///
- /// Typically, the format will be a format description string, or one of the
- /// `time` crate's [well-known formats].
- ///
- /// If the format description is statically known, then the
- /// [`format_description!`] macro should be used. This is identical to the
- /// [`time::format_description::parse`] method, but runs at compile-time,
- /// throwing an error if the format description is invalid. If the desired format
- /// is not known statically (e.g., a user is providing a format string), then the
- /// [`time::format_description::parse`] method should be used. Note that this
- /// method is fallible.
- ///
- /// See the [`time` book] for details on the format description syntax.
- ///
- /// # Examples
- ///
- /// Using the [`format_description!`] macro:
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::LocalTime};
- /// use time::macros::format_description;
- ///
- /// let timer = LocalTime::new(format_description!("[hour]:[minute]:[second]"));
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// Using [`time::format_description::parse`]:
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::LocalTime};
- ///
- /// let time_format = time::format_description::parse("[hour]:[minute]:[second]")
- /// .expect("format string should be valid!");
- /// let timer = LocalTime::new(time_format);
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// Using the [`format_description!`] macro requires enabling the `time`
- /// crate's "macros" feature flag.
- ///
- /// Using a [well-known format][well-known formats] (this is equivalent to
- /// [`LocalTime::rfc_3339`]):
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::LocalTime};
- ///
- /// let timer = LocalTime::new(time::format_description::well_known::Rfc3339);
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// [local time]: time::OffsetDateTime::now_local()
- /// [`time` crate]: time
- /// [`Formattable`]: time::formatting::Formattable
- /// [well-known formats]: time::format_description::well_known
- /// [`format_description!`]: time::macros::format_description!
- /// [`time::format_description::parse`]: time::format_description::parse()
- /// [`time` book]: https://time-rs.github.io/book/api/format-description.html
- pub fn new(format: F) -> Self {
- Self { format }
- }
-}
-
-#[cfg(feature = "local-time")]
-impl<F> FormatTime for LocalTime<F>
-where
- F: Formattable,
-{
- fn format_time(&self, w: &mut Writer<'_>) -> fmt::Result {
- let now = OffsetDateTime::now_local().map_err(|_| fmt::Error)?;
- format_datetime(now, w, &self.format)
- }
-}
-
-#[cfg(feature = "local-time")]
-impl<F> Default for LocalTime<F>
-where
- F: Formattable + Default,
-{
- fn default() -> Self {
- Self::new(F::default())
- }
-}
-
-// === impl UtcTime ===
-
-impl UtcTime<well_known::Rfc3339> {
- /// Returns a formatter that formats the current [UTC time] in the
- /// [RFC 3339] format, which is a subset of the [ISO 8601] timestamp format.
- ///
- /// # Examples
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time};
- ///
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(time::UtcTime::rfc_3339());
- /// # drop(collector);
- /// ```
- ///
- /// [local time]: time::OffsetDateTime::now_utc
- /// [RFC 3339]: https://datatracker.ietf.org/doc/html/rfc3339
- /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601
- pub fn rfc_3339() -> Self {
- Self::new(well_known::Rfc3339)
- }
-}
-
-impl<F: Formattable> UtcTime<F> {
- /// Returns a formatter that formats the current [UTC time] using the
- /// [`time` crate], with the provided provided format. The format may be any
- /// type that implements the [`Formattable`] trait.
- ///
- /// Typically, the format will be a format description string, or one of the
- /// `time` crate's [well-known formats].
- ///
- /// If the format description is statically known, then the
- /// [`format_description!`] macro should be used. This is identical to the
- /// [`time::format_description::parse`] method, but runs at compile-time,
- /// failing an error if the format description is invalid. If the desired format
- /// is not known statically (e.g., a user is providing a format string), then the
- /// [`time::format_description::parse`] method should be used. Note that this
- /// method is fallible.
- ///
- /// See the [`time` book] for details on the format description syntax.
- ///
- /// # Examples
- ///
- /// Using the [`format_description!`] macro:
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::UtcTime};
- /// use time::macros::format_description;
- ///
- /// let timer = UtcTime::new(format_description!("[hour]:[minute]:[second]"));
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// Using the [`format_description!`] macro requires enabling the `time`
- /// crate's "macros" feature flag.
- ///
- /// Using [`time::format_description::parse`]:
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::UtcTime};
- ///
- /// let time_format = time::format_description::parse("[hour]:[minute]:[second]")
- /// .expect("format string should be valid!");
- /// let timer = UtcTime::new(time_format);
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// Using a [well-known format][well-known formats] (this is equivalent to
- /// [`UtcTime::rfc_3339`]):
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::UtcTime};
- ///
- /// let timer = UtcTime::new(time::format_description::well_known::Rfc3339);
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// [UTC time]: time::OffsetDateTime::now_utc()
- /// [`time` crate]: time
- /// [`Formattable`]: time::formatting::Formattable
- /// [well-known formats]: time::format_description::well_known
- /// [`format_description!`]: time::macros::format_description!
- /// [`time::format_description::parse`]: time::format_description::parse
- /// [`time` book]: https://time-rs.github.io/book/api/format-description.html
- pub fn new(format: F) -> Self {
- Self { format }
- }
-}
-
-impl<F> FormatTime for UtcTime<F>
-where
- F: Formattable,
-{
- fn format_time(&self, w: &mut Writer<'_>) -> fmt::Result {
- format_datetime(OffsetDateTime::now_utc(), w, &self.format)
- }
-}
-
-impl<F> Default for UtcTime<F>
-where
- F: Formattable + Default,
-{
- fn default() -> Self {
- Self::new(F::default())
- }
-}
-
-// === impl OffsetTime ===
-
-#[cfg(feature = "local-time")]
-impl OffsetTime<well_known::Rfc3339> {
- /// Returns a formatter that formats the current time using the [local time offset] in the [RFC
- /// 3339] format (a subset of the [ISO 8601] timestamp format).
- ///
- /// Returns an error if the local time offset cannot be determined. This typically occurs in
- /// multithreaded programs. To avoid this problem, initialize `OffsetTime` before forking
- /// threads. When using Tokio, this means initializing `OffsetTime` before the Tokio runtime.
- ///
- /// # Examples
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time};
- ///
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(time::OffsetTime::local_rfc_3339().expect("could not get local offset!"));
- /// # drop(collector);
- /// ```
- ///
- /// Using `OffsetTime` with Tokio:
- ///
- /// ```
- /// use tracing_subscriber::fmt::time::OffsetTime;
- ///
- /// #[tokio::main]
- /// async fn run() {
- /// tracing::info!("runtime initialized");
- ///
- /// // At this point the Tokio runtime is initialized, and we can use both Tokio and Tracing
- /// // normally.
- /// }
- ///
- /// fn main() {
- /// // Because we need to get the local offset before Tokio spawns any threads, our `main`
- /// // function cannot use `tokio::main`.
- /// tracing_subscriber::fmt()
- /// .with_timer(OffsetTime::local_rfc_3339().expect("could not get local time offset"))
- /// .init();
- ///
- /// // Even though `run` is written as an `async fn`, because we used `tokio::main` on it
- /// // we can call it as a synchronous function.
- /// run();
- /// }
- /// ```
- ///
- /// [local time offset]: time::UtcOffset::current_local_offset
- /// [RFC 3339]: https://datatracker.ietf.org/doc/html/rfc3339
- /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601
- pub fn local_rfc_3339() -> Result<Self, time::error::IndeterminateOffset> {
- Ok(Self::new(
- UtcOffset::current_local_offset()?,
- well_known::Rfc3339,
- ))
- }
-}
-
-impl<F: time::formatting::Formattable> OffsetTime<F> {
- /// Returns a formatter that formats the current time using the [`time` crate] with the provided
- /// provided format and [timezone offset]. The format may be any type that implements the
- /// [`Formattable`] trait.
- ///
- ///
- /// Typically, the offset will be the [local offset], and format will be a format description
- /// string, or one of the `time` crate's [well-known formats].
- ///
- /// If the format description is statically known, then the
- /// [`format_description!`] macro should be used. This is identical to the
- /// [`time::format_description::parse`] method, but runs at compile-time,
- /// throwing an error if the format description is invalid. If the desired format
- /// is not known statically (e.g., a user is providing a format string), then the
- /// [`time::format_description::parse`] method should be used. Note that this
- /// method is fallible.
- ///
- /// See the [`time` book] for details on the format description syntax.
- ///
- /// # Examples
- ///
- /// Using the [`format_description!`] macro:
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::OffsetTime};
- /// use time::macros::format_description;
- /// use time::UtcOffset;
- ///
- /// let offset = UtcOffset::current_local_offset().expect("should get local offset!");
- /// let timer = OffsetTime::new(offset, format_description!("[hour]:[minute]:[second]"));
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// Using [`time::format_description::parse`]:
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::OffsetTime};
- /// use time::UtcOffset;
- ///
- /// let offset = UtcOffset::current_local_offset().expect("should get local offset!");
- /// let time_format = time::format_description::parse("[hour]:[minute]:[second]")
- /// .expect("format string should be valid!");
- /// let timer = OffsetTime::new(offset, time_format);
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// Using the [`format_description!`] macro requires enabling the `time`
- /// crate's "macros" feature flag.
- ///
- /// Using a [well-known format][well-known formats] (this is equivalent to
- /// [`OffsetTime::local_rfc_3339`]):
- ///
- /// ```
- /// use tracing_subscriber::fmt::{self, time::OffsetTime};
- /// use time::UtcOffset;
- ///
- /// let offset = UtcOffset::current_local_offset().expect("should get local offset!");
- /// let timer = OffsetTime::new(offset, time::format_description::well_known::Rfc3339);
- /// let collector = tracing_subscriber::fmt()
- /// .with_timer(timer);
- /// # drop(collector);
- /// ```
- ///
- /// [`time` crate]: time
- /// [timezone offset]: time::UtcOffset
- /// [`Formattable`]: time::formatting::Formattable
- /// [local offset]: time::UtcOffset::current_local_offset()
- /// [well-known formats]: time::format_description::well_known
- /// [`format_description!`]: time::macros::format_description
- /// [`time::format_description::parse`]: time::format_description::parse
- /// [`time` book]: https://time-rs.github.io/book/api/format-description.html
- pub fn new(offset: time::UtcOffset, format: F) -> Self {
- Self { offset, format }
- }
-}
-
-impl<F> FormatTime for OffsetTime<F>
-where
- F: time::formatting::Formattable,
-{
- fn format_time(&self, w: &mut Writer<'_>) -> fmt::Result {
- let now = OffsetDateTime::now_utc().to_offset(self.offset);
- format_datetime(now, w, &self.format)
- }
-}
-
-fn format_datetime(
- now: OffsetDateTime,
- into: &mut Writer<'_>,
- fmt: &impl Formattable,
-) -> fmt::Result {
- let mut into = WriteAdaptor::new(into);
- now.format_into(&mut into, fmt)
- .map_err(|_| fmt::Error)
- .map(|_| ())
-}