Commit 3f856a6
committed
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 <[email protected]>1 parent b486867 commit 3f856a6
File tree
4 files changed
+95
-40
lines changed- tracing-subscriber/src/fmt
- format
4 files changed
+95
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
753 | 753 | | |
754 | 754 | | |
755 | 755 | | |
| 756 | + | |
| 757 | + | |
756 | 758 | | |
757 | 759 | | |
758 | 760 | | |
759 | | - | |
| 761 | + | |
760 | 762 | | |
761 | | - | |
762 | 763 | | |
763 | 764 | | |
764 | 765 | | |
765 | 766 | | |
766 | | - | |
| 767 | + | |
767 | 768 | | |
768 | 769 | | |
769 | 770 | | |
770 | 771 | | |
771 | | - | |
772 | 772 | | |
773 | 773 | | |
774 | 774 | | |
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
781 | | - | |
| 781 | + | |
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
785 | | - | |
| 785 | + | |
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
790 | | - | |
| 790 | + | |
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
795 | | - | |
| 795 | + | |
796 | 796 | | |
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
801 | | - | |
| 801 | + | |
802 | 802 | | |
803 | 803 | | |
804 | 804 | | |
| |||
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
837 | | - | |
838 | | - | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
839 | 855 | | |
840 | 856 | | |
841 | | - | |
| 857 | + | |
842 | 858 | | |
843 | 859 | | |
844 | | - | |
845 | 860 | | |
846 | 861 | | |
847 | 862 | | |
| |||
870 | 885 | | |
871 | 886 | | |
872 | 887 | | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | 888 | | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
886 | 917 | | |
887 | 918 | | |
888 | 919 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
244 | 247 | | |
245 | | - | |
| 248 | + | |
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
| |||
980 | 983 | | |
981 | 984 | | |
982 | 985 | | |
983 | | - | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
984 | 993 | | |
985 | 994 | | |
986 | 995 | | |
| |||
1108 | 1117 | | |
1109 | 1118 | | |
1110 | 1119 | | |
1111 | | - | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
1112 | 1127 | | |
1113 | 1128 | | |
1114 | 1129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
317 | 326 | | |
318 | 327 | | |
319 | 328 | | |
| |||
329 | 338 | | |
330 | 339 | | |
331 | 340 | | |
332 | | - | |
| 341 | + | |
333 | 342 | | |
334 | | - | |
| 343 | + | |
335 | 344 | | |
336 | 345 | | |
337 | 346 | | |
| |||
0 commit comments