-
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
feat: mark builders as must_use #2239
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
Jul 21, 2022
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.
thanks! i'd been meaning to do this myself for a while but hadn't gotten around to it, so thank you for doing it!
as a follow-up, we probably also want to stick #[must_use]
attributes on basically any new()
or similar constructors, as well...
hawkw
pushed a commit
that referenced
this pull request
Jul 29, 2022
## Motivation Builders not marked `#[must_use]` can not be initialized sometimes, causing silent failures. Eg. ```rust fn main() { tracing_subscriber::fmt(); tracing::info!("hello"); } ``` won't print anything. ## Solution Added `#[must_use]` to builder types in the tracing-subscriber crate.
hawkw
pushed a commit
that referenced
this pull request
Jul 29, 2022
## Motivation Builders not marked `#[must_use]` can not be initialized sometimes, causing silent failures. Eg. ```rust fn main() { tracing_subscriber::fmt(); tracing::info!("hello"); } ``` won't print anything. ## Solution Added `#[must_use]` to builder types in the tracing-subscriber crate.
hawkw
pushed a commit
that referenced
this pull request
Aug 10, 2022
## Motivation Follow up to #2239. Discovered that ```rust tracing_subscriber::fmt().with_ansi(false).finish(); tracing::info!("hello"); ``` doesn't actually do anything, because `finish` returns a `Collector` and `init` is the thing that actually installs the collector. ## Solution Added `#[must_use]` which suggests using `try_init` instead.
hawkw
added a commit
that referenced
this pull request
Oct 6, 2022
# 0.3.16 (October 6, 2022) This release of `tracing-subscriber` fixes a regression introduced in [v0.3.15][subscriber-0.3.15] where `Option::None`'s `Layer` implementation would set the max level hint to `OFF`. In addition, it adds several new APIs, including the `Filter::event_enabled` method for filtering events based on fields values, and the ability to log internal errors that occur when writing a log line. This release also replaces the dependency on the unmaintained [`ansi-term`] crate with the [`nu-ansi-term`] crate, resolving an *informational* security advisory ([RUSTSEC-2021-0139] for [`ansi-term`]'s maintainance status. This increases the minimum supported Rust version (MSRV) to Rust 1.50+, although the crate should still compile for the previous MSRV of Rust 1.49+ when the `ansi` feature is not enabled. ### Fixed - **layer**: `Option::None`'s `Layer` impl always setting the `max_level_hint` to `LevelFilter::OFF` (#2321) - Compilation with `-Z minimal versions` (#2246) - **env-filter**: Clarify that disabled level warnings are emitted by `tracing-subscriber` (#2285) ### Added - **fmt**: Log internal errors to `stderr` if writing a log line fails (#2102) - **fmt**: `FmtLayer::log_internal_errors` and `FmtSubscriber::log_internal_errors` methods for configuring whether internal writer errors are printed to `stderr` (#2102) - **fmt**: `#[must_use]` attributes on builders to warn if a `Subscriber` is configured but not set as the default subscriber (#2239) - **filter**: `Filter::event_enabled` method for filtering an event based on its fields (#2245, #2251) - **filter**: `Targets::default_level` accessor (#2242) ### Changed - **ansi**: Replaced dependency on unmaintained `ansi-term` crate with `nu-ansi-term` ((#2287, fixes informational advisory [RUSTSEC-2021-0139]) - `tracing-core`: updated to [0.1.30][core-0.1.30] - Minimum Supported Rust Version (MSRV) increased to Rust 1.50+ (when the `ansi`) feature flag is enabled (#2287) ### Documented - **fmt**: Correct inaccuracies in `fmt::init` documentation (#2224) - **filter**: Fix incorrect doc link in `filter::Not` combinator (#2249) Thanks to new contributors @cgbur, @DesmondWillowbrook, @RalfJung, and @poliorcetics, as well as returning contributors @CAD97, @connec, @jswrenn, @guswynn, and @bryangarza, for contributing to this release! [nu-ansi-term]: https://github.com/nushell/nu-ansi-term [ansi_term]: https://github.com/ogham/rust-ansi-term [RUSTSEC-2021-0139]: https://rustsec.org/advisories/RUSTSEC-2021-0139.html [core-0.1.30]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.30 [subscriber-0.3.15]: https://github.com/tokio-rs/tracing/releases/tag/tracing-subscriber-0.3.15
hawkw
added a commit
that referenced
this pull request
Oct 6, 2022
# 0.3.16 (October 6, 2022) This release of `tracing-subscriber` fixes a regression introduced in [v0.3.15][subscriber-0.3.15] where `Option::None`'s `Layer` implementation would set the max level hint to `OFF`. In addition, it adds several new APIs, including the `Filter::event_enabled` method for filtering events based on fields values, and the ability to log internal errors that occur when writing a log line. This release also replaces the dependency on the unmaintained [`ansi-term`] crate with the [`nu-ansi-term`] crate, resolving an *informational* security advisory ([RUSTSEC-2021-0139] for [`ansi-term`]'s maintainance status. This increases the minimum supported Rust version (MSRV) to Rust 1.50+, although the crate should still compile for the previous MSRV of Rust 1.49+ when the `ansi` feature is not enabled. ### Fixed - **layer**: `Option::None`'s `Layer` impl always setting the `max_level_hint` to `LevelFilter::OFF` (#2321) - Compilation with `-Z minimal versions` (#2246) - **env-filter**: Clarify that disabled level warnings are emitted by `tracing-subscriber` (#2285) ### Added - **fmt**: Log internal errors to `stderr` if writing a log line fails (#2102) - **fmt**: `FmtLayer::log_internal_errors` and `FmtSubscriber::log_internal_errors` methods for configuring whether internal writer errors are printed to `stderr` (#2102) - **fmt**: `#[must_use]` attributes on builders to warn if a `Subscriber` is configured but not set as the default subscriber (#2239) - **filter**: `Filter::event_enabled` method for filtering an event based on its fields (#2245, #2251) - **filter**: `Targets::default_level` accessor (#2242) ### Changed - **ansi**: Replaced dependency on unmaintained `ansi-term` crate with `nu-ansi-term` ((#2287, fixes informational advisory [RUSTSEC-2021-0139]) - `tracing-core`: updated to [0.1.30][core-0.1.30] - Minimum Supported Rust Version (MSRV) increased to Rust 1.50+ (when the `ansi`) feature flag is enabled (#2287) ### Documented - **fmt**: Correct inaccuracies in `fmt::init` documentation (#2224) - **filter**: Fix incorrect doc link in `filter::Not` combinator (#2249) Thanks to new contributors @cgbur, @DesmondWillowbrook, @RalfJung, and @poliorcetics, as well as returning contributors @CAD97, @connec, @jswrenn, @guswynn, and @bryangarza, for contributing to this release! [nu-ansi-term]: https://github.com/nushell/nu-ansi-term [ansi_term]: https://github.com/ogham/rust-ansi-term [RUSTSEC-2021-0139]: https://rustsec.org/advisories/RUSTSEC-2021-0139.html [core-0.1.30]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.30 [subscriber-0.3.15]: https://github.com/tokio-rs/tracing/releases/tag/tracing-subscriber-0.3.15
hawkw
added a commit
that referenced
this pull request
Oct 6, 2022
# 0.3.16 (October 6, 2022) This release of `tracing-subscriber` fixes a regression introduced in [v0.3.15][subscriber-0.3.15] where `Option::None`'s `Layer` implementation would set the max level hint to `OFF`. In addition, it adds several new APIs, including the `Filter::event_enabled` method for filtering events based on fields values, and the ability to log internal errors that occur when writing a log line. This release also replaces the dependency on the unmaintained [`ansi-term`] crate with the [`nu-ansi-term`] crate, resolving an *informational* security advisory ([RUSTSEC-2021-0139] for [`ansi-term`]'s maintainance status. This increases the minimum supported Rust version (MSRV) to Rust 1.50+, although the crate should still compile for the previous MSRV of Rust 1.49+ when the `ansi` feature is not enabled. ### Fixed - **layer**: `Option::None`'s `Layer` impl always setting the `max_level_hint` to `LevelFilter::OFF` (#2321) - Compilation with `-Z minimal versions` (#2246) - **env-filter**: Clarify that disabled level warnings are emitted by `tracing-subscriber` (#2285) ### Added - **fmt**: Log internal errors to `stderr` if writing a log line fails (#2102) - **fmt**: `FmtLayer::log_internal_errors` and `FmtSubscriber::log_internal_errors` methods for configuring whether internal writer errors are printed to `stderr` (#2102) - **fmt**: `#[must_use]` attributes on builders to warn if a `Subscriber` is configured but not set as the default subscriber (#2239) - **filter**: `Filter::event_enabled` method for filtering an event based on its fields (#2245, #2251) - **filter**: `Targets::default_level` accessor (#2242) ### Changed - **ansi**: Replaced dependency on unmaintained `ansi-term` crate with `nu-ansi-term` ((#2287, fixes informational advisory [RUSTSEC-2021-0139]) - `tracing-core`: updated to [0.1.30][core-0.1.30] - Minimum Supported Rust Version (MSRV) increased to Rust 1.50+ (when the `ansi`) feature flag is enabled (#2287) ### Documented - **fmt**: Correct inaccuracies in `fmt::init` documentation (#2224) - **filter**: Fix incorrect doc link in `filter::Not` combinator (#2249) Thanks to new contributors @cgbur, @DesmondWillowbrook, @RalfJung, and @poliorcetics, as well as returning contributors @CAD97, @connec, @jswrenn, @guswynn, and @bryangarza, for contributing to this release! [nu-ansi-term]: https://github.com/nushell/nu-ansi-term [ansi_term]: https://github.com/ogham/rust-ansi-term [RUSTSEC-2021-0139]: https://rustsec.org/advisories/RUSTSEC-2021-0139.html [core-0.1.30]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.30 [subscriber-0.3.15]: https://github.com/tokio-rs/tracing/releases/tag/tracing-subscriber-0.3.15
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
# 0.3.16 (October 6, 2022) This release of `tracing-subscriber` fixes a regression introduced in [v0.3.15][subscriber-0.3.15] where `Option::None`'s `Layer` implementation would set the max level hint to `OFF`. In addition, it adds several new APIs, including the `Filter::event_enabled` method for filtering events based on fields values, and the ability to log internal errors that occur when writing a log line. This release also replaces the dependency on the unmaintained [`ansi-term`] crate with the [`nu-ansi-term`] crate, resolving an *informational* security advisory ([RUSTSEC-2021-0139] for [`ansi-term`]'s maintainance status. This increases the minimum supported Rust version (MSRV) to Rust 1.50+, although the crate should still compile for the previous MSRV of Rust 1.49+ when the `ansi` feature is not enabled. ### Fixed - **layer**: `Option::None`'s `Layer` impl always setting the `max_level_hint` to `LevelFilter::OFF` (tokio-rs#2321) - Compilation with `-Z minimal versions` (tokio-rs#2246) - **env-filter**: Clarify that disabled level warnings are emitted by `tracing-subscriber` (tokio-rs#2285) ### Added - **fmt**: Log internal errors to `stderr` if writing a log line fails (tokio-rs#2102) - **fmt**: `FmtLayer::log_internal_errors` and `FmtSubscriber::log_internal_errors` methods for configuring whether internal writer errors are printed to `stderr` (tokio-rs#2102) - **fmt**: `#[must_use]` attributes on builders to warn if a `Subscriber` is configured but not set as the default subscriber (tokio-rs#2239) - **filter**: `Filter::event_enabled` method for filtering an event based on its fields (tokio-rs#2245, tokio-rs#2251) - **filter**: `Targets::default_level` accessor (tokio-rs#2242) ### Changed - **ansi**: Replaced dependency on unmaintained `ansi-term` crate with `nu-ansi-term` ((tokio-rs#2287, fixes informational advisory [RUSTSEC-2021-0139]) - `tracing-core`: updated to [0.1.30][core-0.1.30] - Minimum Supported Rust Version (MSRV) increased to Rust 1.50+ (when the `ansi`) feature flag is enabled (tokio-rs#2287) ### Documented - **fmt**: Correct inaccuracies in `fmt::init` documentation (tokio-rs#2224) - **filter**: Fix incorrect doc link in `filter::Not` combinator (tokio-rs#2249) Thanks to new contributors @cgbur, @DesmondWillowbrook, @RalfJung, and @poliorcetics, as well as returning contributors @CAD97, @connec, @jswrenn, @guswynn, and @bryangarza, for contributing to this release! [nu-ansi-term]: https://github.com/nushell/nu-ansi-term [ansi_term]: https://github.com/ogham/rust-ansi-term [RUSTSEC-2021-0139]: https://rustsec.org/advisories/RUSTSEC-2021-0139.html [core-0.1.30]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.30 [subscriber-0.3.15]: https://github.com/tokio-rs/tracing/releases/tag/tracing-subscriber-0.3.15
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
Builders not marked
#[must_use]
can not be initialized sometimes, causing silent failures.Eg.
won't print anything.
Solution
Added
#[must_use]
to builder types in the tracing-subscriber crate.