From ce25a64220e1083038925609e3f7fdcc74c48fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sun, 5 Jan 2025 13:28:36 -0800 Subject: [PATCH] subscriber: document Subscriber::with_test_writer() limitations Subscriber::with_test_writer() doesn't compose with any earlier calls of Subscriber::with_writer(), as one would perhaps hope. Rather, both just overwrite the same member. Make sure to add a note of this behavior to make it a bit more obvious. --- tracing-subscriber/src/fmt/fmt_subscriber.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tracing-subscriber/src/fmt/fmt_subscriber.rs b/tracing-subscriber/src/fmt/fmt_subscriber.rs index eec4c3241..7263cf08d 100644 --- a/tracing-subscriber/src/fmt/fmt_subscriber.rs +++ b/tracing-subscriber/src/fmt/fmt_subscriber.rs @@ -266,6 +266,10 @@ impl Subscriber { /// /// See [`TestWriter`] for additional details. /// + /// # Notes + /// Usage of this method is will overwrite the result of a previous [`with_writer`] invocation; + /// the two do not compose. + /// /// # Examples /// /// Using [`TestWriter`] to let `cargo test` capture test output: @@ -283,6 +287,7 @@ impl Subscriber { /// [capturing]: /// https://doc.rust-lang.org/book/ch11-02-running-tests.html#showing-function-output /// [`TestWriter`]: super::writer::TestWriter + /// [`with_ansi`]: Subscriber::with_writer pub fn with_test_writer(self) -> Subscriber { Subscriber { fmt_fields: self.fmt_fields,