-
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
Make format::Writer::new() public #2680
Conversation
A number of people (myself included) have expressed significant interest in having Writer::new() public for various reasons, with some difficulty getting traction.
Kaifastromai public writer new
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 happy to merge this change. I had some additional suggestions about the documentation that I'd like to address before merging this, but I can just apply those suggestions myself and merge the PR.
//(@kaifastromai) I suppose having dedicated constructors may have certain benefits | ||
// but I am not privy to the larger direction of tracing/subscriber. |
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.
If we're committing to making this a public API, I think we can just remove the previous TODO comment.
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.
The motivation for not making this public is that I thought it could be valuable for the Writer
type to be able to indicate whether it was empty or not. This could be used when writing to it, in order to determine whether to emit whitespace before writing more text to the writer. If we were going to track this, however, we couldn't just take an arbitrary impl fmt::Write
, because there is no way to determine whether that value is empty or not. If we had an explicit Writer::from_string
constructor, instead, we could check if the string is empty first. Therefore, my preference would be to do that, and keep the new
function that constructs a Writer
from an arbitrary value private.
However, I honestly don't care anymore, and I'm happy to approve this PR regardless. If we decide that tracking whether the writer is empty is important, we could make a breaking change in the future.
Huzzah! |
## Motivation As seen here #2512 and #2223. Previously pr'ed here #2525, but no progress has been made there for quite some. I have applied the suggested changes. Not sure the formatting of the doc is sufficient or otherwise correct ## Solution Make the `format::Writer::new()` function public. I don't see any obvious trade-offs, but I am not familiar with the larger direction of tracing/subscriber, so I may be wrong. Closes #2512 Closes #2223 Co-authored-by: Cephas Storm <[email protected]> Co-authored-by: Eliza Weisman <[email protected]>
## Motivation As seen here #2512 and #2223. Previously pr'ed here #2525, but no progress has been made there for quite some. I have applied the suggested changes. Not sure the formatting of the doc is sufficient or otherwise correct ## Solution Make the `format::Writer::new()` function public. I don't see any obvious trade-offs, but I am not familiar with the larger direction of tracing/subscriber, so I may be wrong. Closes #2512 Closes #2223 Co-authored-by: Cephas Storm <[email protected]> Co-authored-by: Eliza Weisman <[email protected]>
# 0.3.18 (November 13, 2023) This release of `tracing-subscriber` adds support for the [`NO_COLOR`] environment variable (an informal standard to disable emitting ANSI color escape codes) in `fmt::Layer`, reintroduces support for the [`chrono`] crate, and increases the minimum supported Rust version (MSRV) to Rust 1.63.0. It also introduces several minor API improvements. ### Added - **chrono**: Add [`chrono`] implementations of `FormatTime` ([#2690]) - **subscriber**: Add support for the [`NO_COLOR`] environment variable in `fmt::Layer` ([#2647]) - **fmt**: make `format::Writer::new()` public ([#2680]) - **filter**: Implement `layer::Filter` for `Option<Filter>` ([#2407]) ### Changed - **log**: bump version of `tracing-log` to 0.2 ([#2772]) - Increased minimum supported Rust version (MSRV) to 1.63.0+. [`chrono`]: https://github.com/chronotope/chrono [`NO_COLOR`]: https://no-color.org/ [#2690]: #2690 [#2647]: #2647 [#2680]: #2680 [#2407]: #2407 [#2772]: #2772 Thanks to @shayne-fletcher, @dmlary, @kaifastromai, and @jsgf for contributing!
## Motivation As seen here tokio-rs#2512 and tokio-rs#2223. Previously pr'ed here tokio-rs#2525, but no progress has been made there for quite some. I have applied the suggested changes. Not sure the formatting of the doc is sufficient or otherwise correct ## Solution Make the `format::Writer::new()` function public. I don't see any obvious trade-offs, but I am not familiar with the larger direction of tracing/subscriber, so I may be wrong. Closes tokio-rs#2512 Closes tokio-rs#2223 Co-authored-by: Cephas Storm <[email protected]> Co-authored-by: Eliza Weisman <[email protected]>
# 0.3.18 (November 13, 2023) This release of `tracing-subscriber` adds support for the [`NO_COLOR`] environment variable (an informal standard to disable emitting ANSI color escape codes) in `fmt::Layer`, reintroduces support for the [`chrono`] crate, and increases the minimum supported Rust version (MSRV) to Rust 1.63.0. It also introduces several minor API improvements. ### Added - **chrono**: Add [`chrono`] implementations of `FormatTime` ([tokio-rs#2690]) - **subscriber**: Add support for the [`NO_COLOR`] environment variable in `fmt::Layer` ([tokio-rs#2647]) - **fmt**: make `format::Writer::new()` public ([tokio-rs#2680]) - **filter**: Implement `layer::Filter` for `Option<Filter>` ([tokio-rs#2407]) ### Changed - **log**: bump version of `tracing-log` to 0.2 ([tokio-rs#2772]) - Increased minimum supported Rust version (MSRV) to 1.63.0+. [`chrono`]: https://github.com/chronotope/chrono [`NO_COLOR`]: https://no-color.org/ [tokio-rs#2690]: tokio-rs#2690 [tokio-rs#2647]: tokio-rs#2647 [tokio-rs#2680]: tokio-rs#2680 [tokio-rs#2407]: tokio-rs#2407 [tokio-rs#2772]: tokio-rs#2772 Thanks to @shayne-fletcher, @dmlary, @kaifastromai, and @jsgf for contributing!
# 0.3.18 (November 13, 2023) This release of `tracing-subscriber` adds support for the [`NO_COLOR`] environment variable (an informal standard to disable emitting ANSI color escape codes) in `fmt::Layer`, reintroduces support for the [`chrono`] crate, and increases the minimum supported Rust version (MSRV) to Rust 1.63.0. It also introduces several minor API improvements. ### Added - **chrono**: Add [`chrono`] implementations of `FormatTime` ([tokio-rs#2690]) - **subscriber**: Add support for the [`NO_COLOR`] environment variable in `fmt::Layer` ([tokio-rs#2647]) - **fmt**: make `format::Writer::new()` public ([tokio-rs#2680]) - **filter**: Implement `layer::Filter` for `Option<Filter>` ([tokio-rs#2407]) ### Changed - **log**: bump version of `tracing-log` to 0.2 ([tokio-rs#2772]) - Increased minimum supported Rust version (MSRV) to 1.63.0+. [`chrono`]: https://github.com/chronotope/chrono [`NO_COLOR`]: https://no-color.org/ [tokio-rs#2690]: tokio-rs#2690 [tokio-rs#2647]: tokio-rs#2647 [tokio-rs#2680]: tokio-rs#2680 [tokio-rs#2407]: tokio-rs#2407 [tokio-rs#2772]: tokio-rs#2772 Thanks to @shayne-fletcher, @dmlary, @kaifastromai, and @jsgf for contributing!
Motivation
As seen here #2512 and #2223. Previously pr'ed here #2525, but no progress has been made there for quite some. I have applied the suggested changes. Not sure the formatting of the doc is sufficient or otherwise correct
Solution
Make the format::Writer::new() function public. I don't see any obvious trade-offs, but I am not familiar with the larger direction of tracing/subscriber, so I may be wrong.