Skip to content
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

Merged
merged 5 commits into from
Oct 11, 2023
Merged

Conversation

kaifastromai
Copy link
Contributor

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.

A number of people (myself included) have expressed significant interest in having Writer::new() public for various reasons, with some difficulty getting traction.
Copy link
Member

@hawkw hawkw left a 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.

Comment on lines +426 to +427
//(@kaifastromai) I suppose having dedicated constructors may have certain benefits
// but I am not privy to the larger direction of tracing/subscriber.
Copy link
Member

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.

Copy link
Member

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.

tracing-subscriber/src/fmt/format/mod.rs Outdated Show resolved Hide resolved
tracing-subscriber/src/fmt/format/mod.rs Outdated Show resolved Hide resolved
@kaifastromai
Copy link
Contributor Author

Huzzah!

@hawkw hawkw enabled auto-merge (squash) October 10, 2023 23:53
@hawkw hawkw merged commit 99e0377 into tokio-rs:master Oct 11, 2023
55 checks passed
hawkw added a commit that referenced this pull request Oct 12, 2023
## 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 <cephas.storm@borisfx.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
davidbarsky pushed a commit that referenced this pull request Oct 12, 2023
## 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 <cephas.storm@borisfx.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw pushed a commit that referenced this pull request Nov 13, 2023
# 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!
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request Nov 21, 2023
## 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 <cephas.storm@borisfx.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request Feb 14, 2024
# 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!
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
# 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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants