Skip to content

Commit

Permalink
subscriber: fix missing make_writer_for in BoxMakeWriter
Browse files Browse the repository at this point in the history
## 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` (#781), I
accidentally clobbered the `make_writer_for` method on the inner `Boxed`
type, so that it only has `make_writer`:
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 #1694
  • Loading branch information
hawkw committed Oct 29, 2021
1 parent 3bff502 commit 2ad0055
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tracing-subscriber/src/fmt/writer.rs
Expand Up @@ -757,10 +757,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 @@ -778,6 +780,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)
}
}

// === impl Mutex/MutexGuardWriter ===
Expand Down

0 comments on commit 2ad0055

Please sign in to comment.