Skip to content

Commit

Permalink
subscriber: document Subscriber::with_test_writer() limitations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
d-e-s-o committed Jan 5, 2025
1 parent b02a700 commit 6f6ff67
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tracing-subscriber/src/fmt/fmt_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ impl<C, N, E, W> Subscriber<C, N, E, W> {
///
/// 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:
Expand All @@ -283,6 +287,7 @@ impl<C, N, E, W> Subscriber<C, N, E, W> {
/// [capturing]:
/// https://doc.rust-lang.org/book/ch11-02-running-tests.html#showing-function-output
/// [`TestWriter`]: super::writer::TestWriter
/// [`with_writer`]: Subscriber::with_writer
pub fn with_test_writer(self) -> Subscriber<C, N, E, TestWriter> {
Subscriber {
fmt_fields: self.fmt_fields,
Expand Down

0 comments on commit 6f6ff67

Please sign in to comment.