-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subscriber: add MakeWriter
combinators
#1274
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks super cool, modulo warnings and docs! Mind re-upping me for review once that's done?
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
195d9c0
to
20dee71
Compare
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
MakeWriter
combinatorsMakeWriter
combinators
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
…o eliza/output-levels
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
|
||
/// Wraps `self` with a predicate that takes a span or event's [`Metadata`] | ||
/// and returns a `bool`. The returned [`MakeWriter`]'s | ||
/// [`MakeWriter::make_writer_for`][mwf] method will check the predicate to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see mwf
defined as a doc link here. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, my bad --- i forgot to add that.
/// This is not intended to be implemented directly for user-defined | ||
/// [`MakeWriter`]s; instead, it should be imported when the desired methods are | ||
/// used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add this trait to the subscriber prelude?
Co-authored-by: David Barsky <me@davidbarsky.com>
This adds a section to the `Level` docs explaining the comparison rules for `Level` and `LevelFilter`. It turns out this wasn't really explicitly documented anywhere. See #1274 (comment) Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This adds a section to the `Level` docs explaining the comparison rules for `Level` and `LevelFilter`. It turns out this wasn't really explicitly documented anywhere. See #1274 (comment) Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This backports #1274 from `master`. Depends on #1141. This branch adds a `MakeWriterExt` trait which adds a number of combinators for composing multiple types implementing `MakeWriter`. `MakeWriter`s can now be teed together, filtered with minimum and maximum levels, filtered with a `Metadata` predicate, and combined with a fallback for when a writer is _not_ made for a particular `Metadata`. I've also added a `MakeWriter` impl for `Arc<W>` when `&W` implements `Write`. This enables `File`s to be used as `MakeWriter`s similarly to how we will be able to in 0.3, with the additional overhead of having to do ref-counting because we can't return a reference from `MakeWriter` until the next breaking change. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This adds a section to the `Level` docs explaining the comparison rules for `Level` and `LevelFilter`. It turns out this wasn't really explicitly documented anywhere. I may have gone a bit overboard on this, but I think the new docs should be helpful... See #1274 (comment) Signed-off-by: Eliza Weisman <eliza@buoyant.io> Co-authored-by: David Barsky <me@davidbarsky.com>
This adds a section to the `Level` docs explaining the comparison rules for `Level` and `LevelFilter`. It turns out this wasn't really explicitly documented anywhere. I may have gone a bit overboard on this, but I think the new docs should be helpful... See #1274 (comment) Signed-off-by: Eliza Weisman <eliza@buoyant.io> Co-authored-by: David Barsky <me@davidbarsky.com>
This adds a section to the `Level` docs explaining the comparison rules for `Level` and `LevelFilter`. It turns out this wasn't really explicitly documented anywhere. I may have gone a bit overboard on this, but I think the new docs should be helpful... See #1274 (comment) Signed-off-by: Eliza Weisman <eliza@buoyant.io> Co-authored-by: David Barsky <me@davidbarsky.com>
This adds a section to the `Level` docs explaining the comparison rules for `Level` and `LevelFilter`. It turns out this wasn't really explicitly documented anywhere. I may have gone a bit overboard on this, but I think the new docs should be helpful... See #1274 (comment) Signed-off-by: Eliza Weisman <eliza@buoyant.io> Co-authored-by: David Barsky <me@davidbarsky.com>
This backports #1274 from `master`. Depends on #1141. This branch adds a `MakeWriterExt` trait which adds a number of combinators for composing multiple types implementing `MakeWriter`. `MakeWriter`s can now be teed together, filtered with minimum and maximum levels, filtered with a `Metadata` predicate, and combined with a fallback for when a writer is _not_ made for a particular `Metadata`. I've also added a `MakeWriter` impl for `Arc<W>` when `&W` implements `Write`. This enables `File`s to be used as `MakeWriter`s similarly to how we will be able to in 0.3, with the additional overhead of having to do ref-counting because we can't return a reference from `MakeWriter` until the next breaking change. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This adds a section to the `Level` docs explaining the comparison rules for `Level` and `LevelFilter`. It turns out this wasn't really explicitly documented anywhere. I may have gone a bit overboard on this, but I think the new docs should be helpful... See #1274 (comment) Signed-off-by: Eliza Weisman <eliza@buoyant.io> Co-authored-by: David Barsky <me@davidbarsky.com>
# 0.2.19 (June 25, 2021) ### Deprecated - **registry**: `SpanRef::parents`, `SpanRef::from_root`, and `Context::scope` iterators, which are replaced by new `SpanRef::scope` and `Scope::from_root` iterators (#1413) ### Added - **registry**: `SpanRef::scope` method, which returns a leaf-to-root `Iterator` including the leaf span (#1413) - **registry**: `Scope::from_root` method, which reverses the `scope` iterator to iterate root-to-leaf (#1413) - **registry**: `Context::event_span` method, which looks up the parent span of an event (#1434) - **registry**: `Context::event_scope` method, returning a `Scope` iterator over the span scope of an event (#1434) - **fmt**: `MakeWriter::make_writer_for` method, which allows returning a different writer based on a span or event's metadata (#1141) - **fmt**: `MakeWriterExt` trait, with `with_max_level`, `with_min_level`, `with_filter`, `and`, and `or_else` combinators (#1274) - **fmt**: `MakeWriter` implementation for `Arc<W> where &W: io::Write` (#1274) Thanks to @teozkr and @Folyd for contributing to this release!
# 0.2.19 (June 25, 2021) ### Deprecated - **registry**: `SpanRef::parents`, `SpanRef::from_root`, and `Context::scope` iterators, which are replaced by new `SpanRef::scope` and `Scope::from_root` iterators (#1413) ### Added - **registry**: `SpanRef::scope` method, which returns a leaf-to-root `Iterator` including the leaf span (#1413) - **registry**: `Scope::from_root` method, which reverses the `scope` iterator to iterate root-to-leaf (#1413) - **registry**: `Context::event_span` method, which looks up the parent span of an event (#1434) - **registry**: `Context::event_scope` method, returning a `Scope` iterator over the span scope of an event (#1434) - **fmt**: `MakeWriter::make_writer_for` method, which allows returning a different writer based on a span or event's metadata (#1141) - **fmt**: `MakeWriterExt` trait, with `with_max_level`, `with_min_level`, `with_filter`, `and`, and `or_else` combinators (#1274) - **fmt**: `MakeWriter` implementation for `Arc<W> where &W: io::Write` (#1274) Thanks to @teozkr and @Folyd for contributing to this release!
This backports tokio-rs#1274 from `master`. Depends on tokio-rs#1141. This branch adds a `MakeWriterExt` trait which adds a number of combinators for composing multiple types implementing `MakeWriter`. `MakeWriter`s can now be teed together, filtered with minimum and maximum levels, filtered with a `Metadata` predicate, and combined with a fallback for when a writer is _not_ made for a particular `Metadata`. I've also added a `MakeWriter` impl for `Arc<W>` when `&W` implements `Write`. This enables `File`s to be used as `MakeWriter`s similarly to how we will be able to in 0.3, with the additional overhead of having to do ref-counting because we can't return a reference from `MakeWriter` until the next breaking change. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
# 0.2.19 (June 25, 2021) ### Deprecated - **registry**: `SpanRef::parents`, `SpanRef::from_root`, and `Context::scope` iterators, which are replaced by new `SpanRef::scope` and `Scope::from_root` iterators (tokio-rs#1413) ### Added - **registry**: `SpanRef::scope` method, which returns a leaf-to-root `Iterator` including the leaf span (tokio-rs#1413) - **registry**: `Scope::from_root` method, which reverses the `scope` iterator to iterate root-to-leaf (tokio-rs#1413) - **registry**: `Context::event_span` method, which looks up the parent span of an event (tokio-rs#1434) - **registry**: `Context::event_scope` method, returning a `Scope` iterator over the span scope of an event (tokio-rs#1434) - **fmt**: `MakeWriter::make_writer_for` method, which allows returning a different writer based on a span or event's metadata (tokio-rs#1141) - **fmt**: `MakeWriterExt` trait, with `with_max_level`, `with_min_level`, `with_filter`, `and`, and `or_else` combinators (tokio-rs#1274) - **fmt**: `MakeWriter` implementation for `Arc<W> where &W: io::Write` (tokio-rs#1274) Thanks to @teozkr and @Folyd for contributing to this release!
Depends on #1141.
This branch adds a
MakeWriterExt
trait which adds a number ofcombinators for composing multiple types implementing
MakeWriter
.MakeWriter
s can now be teed together, filtered with minimum andmaximum levels, filtered with a
Metadata
predicate, and combined witha fallback for when a writer is not made for a particular
Metadata
.I've also added a
MakeWriter
impl forstd::fs::File
, because&File
implements
Write
. Ideally, we'd have a default impl ofMakeWriter
for
T where &T: Write
, but that's not possible due to the impl ofMakeWriter
forF: Fn() -> T: Write
. We could add a genericby_ref
adapter for any
T where &T: Write
, though...