Skip to content

Commit

Permalink
subscriber: fix missing make_writer_for in BoxMakeWriter (tokio-r…
Browse files Browse the repository at this point in the history
…s#1695)

## Motivation

In `tracing-subscriber` 0.3.x, `MakeWriter` filtering seems to have
stopped working when using the `BoxMakeWriter` wrapper to erase the type
of a `MakeWriter` implementation. It looks like what happened is that
commit 6cc6c47, which backported the
change to add a lifetime parameter to `MakeWriter` (tokio-rs#781), I
accidentally clobbered the `make_writer_for` method on the inner `Boxed`
type, so that it only has `make_writer`:
tokio-rs@6cc6c47#diff-c5dc275b15a60c1a2d4694da3797f4247c4f2e1e0978fd210dd14452d6746283L737-L739

This meant that any filtering performed by the `MakeWriter` inside the
box is now ignored. My bad!

## Solution

This commit puts back the missing `make_writer_for` method. Whoops!

Fixes tokio-rs#1694
  • Loading branch information
hawkw authored and kaffarell committed May 22, 2024
1 parent b8ec703 commit 81f8724
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tracing-subscriber/src/fmt/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,12 @@ impl fmt::Debug for BoxMakeWriter {
impl<'a> MakeWriter<'a> for BoxMakeWriter {
type Writer = Box<dyn Write + 'a>;

#[inline]
fn make_writer(&'a self) -> Self::Writer {
self.inner.make_writer()
}

#[inline]
fn make_writer_for(&'a self, meta: &Metadata<'_>) -> Self::Writer {
self.inner.make_writer_for(meta)
}
Expand All @@ -758,6 +760,11 @@ where
let w = self.0.make_writer();
Box::new(w)
}

fn make_writer_for(&'a self, meta: &Metadata<'_>) -> Self::Writer {
let w = self.0.make_writer_for(meta);
Box::new(w)
}
}

fn make_writer_for(&'a self, meta: &Metadata<'_>) -> Self::Writer {
Expand Down

0 comments on commit 81f8724

Please sign in to comment.