-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
subscriber: propagate ANSI config via
Writer
(#1696)
## Motivation Currently, whether `tracing-subscriber`'s `fmt` subscriber will ANSI formatting escape codes use is configured on the `Format` type. This means that the configuration is honored by the event formatters implemented in `tracing-subscriber`, but is not easily exposed to those in other crates. Additionally, it's not currently easy to expose the configuration to the field formatter, so it's difficult to implement field formatters that use ANSI escape codes conditionally. Issue #1651 suggested a new API for this, where the writer that's passed in to the event and field formatters provides a method for checking if ANSI escape codes are supported. ## Solution This branch adds a new method to the `Writer` type added in #1661. The `FormatEvent` and `FormatFields` implementations can call `Writer::has_ansi_escapes` to determine whether ANSI escape codes are supported. This is also propagated to `FormattedFields`, so that it can be determined when adding new fields to a preexisting set of formatted fields. Fixes #1661 Signed-off-by: Eliza Weisman <[email protected]>
- Loading branch information
Showing
3 changed files
with
101 additions
and
68 deletions.
There are no files selected for viewing
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
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
Oops, something went wrong.