diff options
Diffstat (limited to 'vendor/tracing-subscriber/src/fmt')
-rw-r--r-- | vendor/tracing-subscriber/src/fmt/fmt_layer.rs | 28 | ||||
-rw-r--r-- | vendor/tracing-subscriber/src/fmt/format/json.rs | 2 | ||||
-rw-r--r-- | vendor/tracing-subscriber/src/fmt/format/mod.rs | 11 | ||||
-rw-r--r-- | vendor/tracing-subscriber/src/fmt/mod.rs | 18 | ||||
-rw-r--r-- | vendor/tracing-subscriber/src/fmt/time/mod.rs | 2 | ||||
-rw-r--r-- | vendor/tracing-subscriber/src/fmt/writer.rs | 2 |
6 files changed, 49 insertions, 14 deletions
diff --git a/vendor/tracing-subscriber/src/fmt/fmt_layer.rs b/vendor/tracing-subscriber/src/fmt/fmt_layer.rs index 6e4e2ac0b..1e0923a54 100644 --- a/vendor/tracing-subscriber/src/fmt/fmt_layer.rs +++ b/vendor/tracing-subscriber/src/fmt/fmt_layer.rs @@ -273,10 +273,32 @@ impl<S, N, E, W> Layer<S, N, E, W> { } } - /// Enable ANSI terminal colors for formatted output. - #[cfg(feature = "ansi")] - #[cfg_attr(docsrs, doc(cfg(feature = "ansi")))] + /// Sets whether or not the formatter emits ANSI terminal escape codes + /// for colors and other text formatting. + /// + /// Enabling ANSI escapes (calling `with_ansi(true)`) requires the "ansi" + /// crate feature flag. Calling `with_ansi(true)` without the "ansi" + /// feature flag enabled will panic if debug assertions are enabled, or + /// print a warning otherwise. + /// + /// This method itself is still available without the feature flag. This + /// is to allow ANSI escape codes to be explicitly *disabled* without + /// having to opt-in to the dependencies required to emit ANSI formatting. + /// This way, code which constructs a formatter that should never emit + /// ANSI escape codes can ensure that they are not used, regardless of + /// whether or not other crates in the dependency graph enable the "ansi" + /// feature flag. pub fn with_ansi(self, ansi: bool) -> Self { + #[cfg(not(feature = "ansi"))] + if ansi { + const ERROR: &str = + "tracing-subscriber: the `ansi` crate feature is required to enable ANSI terminal colors"; + #[cfg(debug_assertions)] + panic!("{}", ERROR); + #[cfg(not(debug_assertions))] + eprintln!("{}", ERROR); + } + Self { is_ansi: ansi, ..self diff --git a/vendor/tracing-subscriber/src/fmt/format/json.rs b/vendor/tracing-subscriber/src/fmt/format/json.rs index c2f4d3755..bf32f7c9a 100644 --- a/vendor/tracing-subscriber/src/fmt/format/json.rs +++ b/vendor/tracing-subscriber/src/fmt/format/json.rs @@ -720,7 +720,7 @@ mod test { ); let span = tracing::info_span!("the span", na = tracing::field::Empty); - span.record("na", &"value"); + span.record("na", "value"); let _enter = span.enter(); tracing::info!("an event inside the root span"); diff --git a/vendor/tracing-subscriber/src/fmt/format/mod.rs b/vendor/tracing-subscriber/src/fmt/format/mod.rs index b8a482e55..fa22c78ec 100644 --- a/vendor/tracing-subscriber/src/fmt/format/mod.rs +++ b/vendor/tracing-subscriber/src/fmt/format/mod.rs @@ -1082,12 +1082,11 @@ 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(":"))?; + write!(writer, "{}{}", dimmed.paint(meta.target()), dimmed.paint(":"))?; needs_space = true; } @@ -1096,7 +1095,7 @@ where if self.display_target { writer.write_char(' ')?; } - write!(writer, "{}{}", bold.paint(filename), dimmed.paint(":"))?; + write!(writer, "{}{}", dimmed.paint(filename), dimmed.paint(":"))?; needs_space = true; } } @@ -1106,9 +1105,9 @@ where write!( writer, "{}{}{}{}", - bold.prefix(), + dimmed.prefix(), line_number, - bold.suffix(), + dimmed.suffix(), dimmed.paint(":") )?; needs_space = true; @@ -2039,7 +2038,7 @@ pub(super) mod test { #[cfg(feature = "ansi")] #[test] fn with_ansi_true() { - let expected = "\u{1b}[2mfake time\u{1b}[0m \u{1b}[32m INFO\u{1b}[0m \u{1b}[1mtracing_subscriber::fmt::format::test\u{1b}[0m\u{1b}[2m:\u{1b}[0m hello\n"; + let expected = "\u{1b}[2mfake time\u{1b}[0m \u{1b}[32m INFO\u{1b}[0m \u{1b}[2mtracing_subscriber::fmt::format::test\u{1b}[0m\u{1b}[2m:\u{1b}[0m hello\n"; test_ansi(true, expected, crate::fmt::Subscriber::builder().compact()) } diff --git a/vendor/tracing-subscriber/src/fmt/mod.rs b/vendor/tracing-subscriber/src/fmt/mod.rs index 025e17504..cfe470475 100644 --- a/vendor/tracing-subscriber/src/fmt/mod.rs +++ b/vendor/tracing-subscriber/src/fmt/mod.rs @@ -16,7 +16,7 @@ //! tracing-subscriber = "0.3" //! ``` //! -//! *Compiler support: [requires `rustc` 1.49+][msrv]* +//! *Compiler support: [requires `rustc` 1.56+][msrv]* //! //! [msrv]: super#supported-rust-versions //! @@ -612,7 +612,21 @@ where } } - /// Enable ANSI encoding for formatted events. + /// Sets whether or not the formatter emits ANSI terminal escape codes + /// for colors and other text formatting. + /// + /// Enabling ANSI escapes (calling `with_ansi(true)`) requires the "ansi" + /// crate feature flag. Calling `with_ansi(true)` without the "ansi" + /// feature flag enabled will panic if debug assertions are enabled, or + /// print a warning otherwise. + /// + /// This method itself is still available without the feature flag. This + /// is to allow ANSI escape codes to be explicitly *disabled* without + /// having to opt-in to the dependencies required to emit ANSI formatting. + /// This way, code which constructs a formatter that should never emit + /// ANSI escape codes can ensure that they are not used, regardless of + /// whether or not other crates in the dependency graph enable the "ansi" + /// feature flag. #[cfg(feature = "ansi")] #[cfg_attr(docsrs, doc(cfg(feature = "ansi")))] pub fn with_ansi(self, ansi: bool) -> SubscriberBuilder<N, format::Format<L, T>, F, W> { diff --git a/vendor/tracing-subscriber/src/fmt/time/mod.rs b/vendor/tracing-subscriber/src/fmt/time/mod.rs index e5b7c83b0..1d1bba240 100644 --- a/vendor/tracing-subscriber/src/fmt/time/mod.rs +++ b/vendor/tracing-subscriber/src/fmt/time/mod.rs @@ -12,7 +12,7 @@ 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(all(unsound_local_offset, feature = "local-time"))))] pub use time_crate::LocalTime; #[cfg(feature = "time")] diff --git a/vendor/tracing-subscriber/src/fmt/writer.rs b/vendor/tracing-subscriber/src/fmt/writer.rs index 3fe945566..2b9f9e973 100644 --- a/vendor/tracing-subscriber/src/fmt/writer.rs +++ b/vendor/tracing-subscriber/src/fmt/writer.rs @@ -16,7 +16,7 @@ use tracing_core::Metadata; /// This trait is already implemented for function pointers and /// immutably-borrowing closures that return an instance of [`io::Write`], such /// as [`io::stdout`] and [`io::stderr`]. Additionally, it is implemented for -/// [`std::sync::Mutex`][mutex] when the tyoe inside the mutex implements +/// [`std::sync::Mutex`][mutex] when the type inside the mutex implements /// [`io::Write`]. /// /// # Examples |