diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/tracing-subscriber/src | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tracing-subscriber/src')
-rw-r--r-- | vendor/tracing-subscriber/src/filter/targets.rs | 55 | ||||
-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 | ||||
-rw-r--r-- | vendor/tracing-subscriber/src/lib.rs | 16 | ||||
-rw-r--r-- | vendor/tracing-subscriber/src/registry/sharded.rs | 4 |
9 files changed, 112 insertions, 26 deletions
diff --git a/vendor/tracing-subscriber/src/filter/targets.rs b/vendor/tracing-subscriber/src/filter/targets.rs index e1407114b..19f2d9908 100644 --- a/vendor/tracing-subscriber/src/filter/targets.rs +++ b/vendor/tracing-subscriber/src/filter/targets.rs @@ -16,6 +16,7 @@ use crate::{ #[cfg(not(feature = "std"))] use alloc::string::String; use core::{ + fmt, iter::{Extend, FilterMap, FromIterator}, slice, str::FromStr, @@ -324,7 +325,7 @@ impl Targets { /// assert_eq!(filter.default_level(), Some(LevelFilter::OFF)); /// ``` pub fn default_level(&self) -> Option<LevelFilter> { - self.0.directives().into_iter().find_map(|d| { + self.0.directives().find_map(|d| { if d.target.is_none() { Some(d.level) } else { @@ -488,6 +489,20 @@ impl<'a> IntoIterator for &'a Targets { } } +impl fmt::Display for Targets { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut directives = self.0.directives(); + if let Some(directive) = directives.next() { + write!(f, "{}", directive)?; + for directive in directives { + write!(f, ",{}", directive)?; + } + } + + Ok(()) + } +} + /// An owning iterator over the [target]-[level] pairs of a `Targets` filter. /// /// This struct is created by the `IntoIterator` trait implementation of [`Targets`]. @@ -778,4 +793,42 @@ mod tests { crate2=debug,crate3=trace,crate3::mod2::mod1=off", ); } + + /// Test that the `fmt::Display` implementation for `Targets` emits a string + /// that can itself be parsed as a `Targets`, and that the parsed `Targets` + /// is equivalent to the original one. + #[test] + fn display_roundtrips() { + fn test_roundtrip(s: &str) { + let filter = expect_parse(s); + // we don't assert that the display output is equivalent to the + // original parsed filter string, because the `Display` impl always + // uses lowercase level names and doesn't use the + // target-without-level shorthand syntax. while they may not be + // textually equivalent, though, they should still *parse* to the + // same filter. + let formatted = filter.to_string(); + let filter2 = match dbg!(&formatted).parse::<Targets>() { + Ok(filter) => filter, + Err(e) => panic!( + "failed to parse formatted filter string {:?}: {}", + formatted, e + ), + }; + assert_eq!(filter, filter2); + } + + test_roundtrip("crate1::mod1=error,crate1::mod2,crate2=debug,crate3=off"); + test_roundtrip( + "crate1::mod1=ERROR,crate1::mod2=WARN,crate1::mod2::mod3=INFO,\ + crate2=DEBUG,crate3=TRACE,crate3::mod2::mod1=OFF", + ); + test_roundtrip( + "crate1::mod1=error,crate1::mod2=warn,crate1::mod2::mod3=info,\ + crate2=debug,crate3=trace,crate3::mod2::mod1=off", + ); + test_roundtrip("crate1::mod1,crate1::mod2,info"); + test_roundtrip("crate1"); + test_roundtrip("info"); + } } 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 diff --git a/vendor/tracing-subscriber/src/lib.rs b/vendor/tracing-subscriber/src/lib.rs index 808923007..761e239af 100644 --- a/vendor/tracing-subscriber/src/lib.rs +++ b/vendor/tracing-subscriber/src/lib.rs @@ -10,7 +10,7 @@ //! `tracing-subscriber` is intended for use by both `Subscriber` authors and //! application authors using `tracing` to instrument their applications. //! -//! *Compiler support: [requires `rustc` 1.50+][msrv]* +//! *Compiler support: [requires `rustc` 1.56+][msrv]* //! //! [msrv]: #supported-rust-versions //! @@ -46,7 +46,7 @@ //! //! ## Feature Flags //! -//! - `std`: Enables APIs that depend on the on the Rust standard library +//! - `std`: Enables APIs that depend on the Rust standard library //! (enabled by default). //! - `alloc`: Depend on [`liballoc`] (enabled by "std"). //! - `env-filter`: Enables the [`EnvFilter`] type, which implements filtering @@ -138,14 +138,14 @@ //! ## Supported Rust Versions //! //! Tracing is built against the latest stable release. The minimum supported -//! version is 1.50. The current Tracing version is not guaranteed to build on +//! version is 1.56. The current Tracing version is not guaranteed to build on //! Rust versions earlier than the minimum supported version. //! //! Tracing follows the same compiler support policies as the rest of the Tokio //! project. The current stable Rust compiler and the three most recent minor //! versions before it will always be supported. For example, if the current -//! stable compiler version is 1.45, the minimum supported version will not be -//! increased past 1.42, three minor versions prior. Increasing the minimum +//! stable compiler version is 1.69, the minimum supported version will not be +//! increased past 1.66, three minor versions prior. Increasing the minimum //! supported compiler version is not considered a semver breaking change as //! long as doing so complies with this policy. //! @@ -158,9 +158,8 @@ //! [`env_logger` crate]: https://crates.io/crates/env_logger //! [`parking_lot`]: https://crates.io/crates/parking_lot //! [`time` crate]: https://crates.io/crates/time -//! [`libstd`]: std -//! [`liballoc`]: alloc -#![doc(html_root_url = "https://docs.rs/tracing-subscriber/0.3.15")] +//! [`liballoc`]: https://doc.rust-lang.org/alloc/index.html +//! [`libstd`]: https://doc.rust-lang.org/std/index.html #![doc( html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png", issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/" @@ -180,7 +179,6 @@ rust_2018_idioms, unreachable_pub, bad_style, - const_err, dead_code, improper_ctypes, non_shorthand_field_patterns, diff --git a/vendor/tracing-subscriber/src/registry/sharded.rs b/vendor/tracing-subscriber/src/registry/sharded.rs index 797899767..88520a2a6 100644 --- a/vendor/tracing-subscriber/src/registry/sharded.rs +++ b/vendor/tracing-subscriber/src/registry/sharded.rs @@ -422,7 +422,7 @@ impl<'a> SpanData<'a> for Data<'a> { } fn metadata(&self) -> &'static Metadata<'static> { - (*self).inner.metadata + self.inner.metadata } fn parent(&self) -> Option<&Id> { @@ -902,7 +902,7 @@ mod tests { drop(span3); - state.assert_closed_in_order(&["child", "parent", "grandparent"]); + state.assert_closed_in_order(["child", "parent", "grandparent"]); }); } } |