forked from tokio-rs/tracing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmt: fix layers with different ANSI settings sharing the same TypeId
Previously, the FormattedFields struct stored the ANSI state as a boolean field, which could lead to inconsistencies when different layers used different ANSI settings (true/false). This happened because we store the FormattedFields in a HashMap using the TypeId as a key which obviously means that ansi=true and ansi=false would have the same key and the same formatted fields. This meant that whichever layer stored its fields first would determine the ANSI formatting for all subsequent layers. This change refactors FormattedFields to use a const generic parameter for the ANSI state, allowing us to store two different FormattedFields (one with and one without ansi). Each layer can now store its fields with the correct ANSI setting without interfering with other layers. Fixes: tokio-rs#1310 Fixes: tokio-rs#1817 Fixes: tokio-rs#3065 Fixes: tokio-rs#3116 Signed-off-by: Gabriel Goller <gabrielgoller123@gmail.com>
- Loading branch information
Showing
4 changed files
with
94 additions
and
39 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
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