-
Notifications
You must be signed in to change notification settings - Fork 734
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
core: add as_str()
for Level
#1413
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hawkw
approved these changes
May 26, 2021
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'm not totally sure what need this meets that isn't already met by the fmt::Display
implementation, but i'm fine with merging it, especially since the log
crate does this.
i had a couple small suggestions, let me know what you think?
Folyd
added a commit
to Folyd/tracing
that referenced
this pull request
May 27, 2021
## Motivation Get the string representation of the `Level` is quite a common usecase. Without this method, I normally need to implement it by myself, which is fairly noisy. ```rust #[inline] fn level_to_str(level: &tracing::Level) -> &'static str { match *level { tracing::Level::TRACE => "TRACE", tracing::Level::DEBUG => "DEBUG", tracing::Level::INFO => "INFO", tracing::Level::WARN => "WARN", tracing::Level::ERROR => "ERROR" } } ``` ## Solution Add an `as_str()` method for `Level`. Similar to [log::Level::as_str()][1]. [1] https://docs.rs/log/0.4.14/log/enum.Level.html#method.as_str
hawkw
pushed a commit
that referenced
this pull request
May 27, 2021
## Motivation Get the string representation of the `Level` is quite a common usecase. Without this method, I normally need to implement it by myself, which is fairly noisy. ```rust #[inline] fn level_to_str(level: &tracing::Level) -> &'static str { match *level { tracing::Level::TRACE => "TRACE", tracing::Level::DEBUG => "DEBUG", tracing::Level::INFO => "INFO", tracing::Level::WARN => "WARN", tracing::Level::ERROR => "ERROR" } } ``` ## Solution Add an `as_str()` method for `Level`. Similar to [log::Level::as_str()][1]. [1]: https://docs.rs/log/0.4.14/log/enum.Level.html#method.as_str
hawkw
added a commit
that referenced
this pull request
Jun 26, 2021
# 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!
hawkw
added a commit
that referenced
this pull request
Jun 26, 2021
# 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!
hawkw
added a commit
that referenced
this pull request
Aug 17, 2021
# 0.1.19 (August 17, 2021) ### Added - `Level::as_str` ([#1413]) - `Hash` implementation for `Level` and `LevelFilter` ([#1456]) - `Value` implementation for `&mut T where T: Value` ([#1385]) - Multiple documentation fixes and improvements ([#1435], [#1446]) Thanks to @Folyd, @teozkr, and @dvdplm for contributing to this release! [#1413]: #1413 [#1456]: #1456 [#1385]: #1385 [#1435]: #1435 [#1446]: #1446 Signed-off-by: Eliza Weisman <[email protected]>
hawkw
added a commit
that referenced
this pull request
Aug 17, 2021
# 0.1.19 (August 17, 2021) ### Added - `Level::as_str` ([#1413]) - `Hash` implementation for `Level` and `LevelFilter` ([#1456]) - `Value` implementation for `&mut T where T: Value` ([#1385]) - Multiple documentation fixes and improvements ([#1435], [#1446]) Thanks to @Folyd, @teozkr, and @dvdplm for contributing to this release! [#1413]: #1413 [#1456]: #1456 [#1385]: #1385 [#1435]: #1435 [#1446]: #1446 Signed-off-by: Eliza Weisman <[email protected]>
hawkw
added a commit
that referenced
this pull request
Aug 17, 2021
# 0.1.19 (August 17, 2021) ### Added - `Level::as_str` ([#1413]) - `Hash` implementation for `Level` and `LevelFilter` ([#1456]) - `Value` implementation for `&mut T where T: Value` ([#1385]) - Multiple documentation fixes and improvements ([#1435], [#1446]) Thanks to @Folyd, @teozkr, and @dvdplm for contributing to this release! [#1413]: #1413 [#1456]: #1456 [#1385]: #1385 [#1435]: #1435 [#1446]: #1446 Signed-off-by: Eliza Weisman <[email protected]>
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
# 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!
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
# 0.1.19 (August 17, 2021) ### Added - `Level::as_str` ([tokio-rs#1413]) - `Hash` implementation for `Level` and `LevelFilter` ([tokio-rs#1456]) - `Value` implementation for `&mut T where T: Value` ([tokio-rs#1385]) - Multiple documentation fixes and improvements ([tokio-rs#1435], [tokio-rs#1446]) Thanks to @Folyd, @teozkr, and @dvdplm for contributing to this release! [tokio-rs#1413]: tokio-rs#1413 [tokio-rs#1456]: tokio-rs#1456 [tokio-rs#1385]: tokio-rs#1385 [tokio-rs#1435]: tokio-rs#1435 [tokio-rs#1446]: tokio-rs#1446 Signed-off-by: Eliza Weisman <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Get the string representation of the
Level
is quite a common usecase.Without this method, I normally need to implement it by myself, which is fairly noisy.
Solution
Add an
as_str()
method forLevel
. Similar to log::Level::as_str().