Commit 0a16972
authored
subscriber: propagate ANSI config via
This backports PR #1696 to v0.1.x.
## 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 #1651
Signed-off-by: Eliza Weisman <eliza@buoyant.io>Writer (#1696)1 parent a39261f commit 0a16972
File tree
3 files changed
+160
-161
lines changed- tracing-subscriber/src/fmt
- format
3 files changed
+160
-161
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| |||
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
| 156 | + | |
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| |||
183 | 186 | | |
184 | 187 | | |
185 | 188 | | |
| 189 | + | |
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
189 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
190 | 204 | | |
191 | 205 | | |
192 | 206 | | |
| |||
213 | 227 | | |
214 | 228 | | |
215 | 229 | | |
| 230 | + | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
| |||
224 | 239 | | |
225 | 240 | | |
226 | 241 | | |
| 242 | + | |
227 | 243 | | |
228 | 244 | | |
229 | 245 | | |
| |||
276 | 292 | | |
277 | 293 | | |
278 | 294 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | 295 | | |
290 | 296 | | |
291 | 297 | | |
| |||
337 | 343 | | |
338 | 344 | | |
339 | 345 | | |
| 346 | + | |
340 | 347 | | |
341 | 348 | | |
342 | 349 | | |
| |||
350 | 357 | | |
351 | 358 | | |
352 | 359 | | |
| 360 | + | |
353 | 361 | | |
354 | 362 | | |
355 | 363 | | |
| |||
378 | 386 | | |
379 | 387 | | |
380 | 388 | | |
| 389 | + | |
| 390 | + | |
381 | 391 | | |
382 | 392 | | |
383 | 393 | | |
| |||
443 | 453 | | |
444 | 454 | | |
445 | 455 | | |
| 456 | + | |
446 | 457 | | |
447 | 458 | | |
448 | 459 | | |
| |||
455 | 466 | | |
456 | 467 | | |
457 | 468 | | |
| 469 | + | |
458 | 470 | | |
459 | 471 | | |
460 | 472 | | |
| |||
488 | 500 | | |
489 | 501 | | |
490 | 502 | | |
| 503 | + | |
491 | 504 | | |
492 | 505 | | |
493 | 506 | | |
| |||
497 | 510 | | |
498 | 511 | | |
499 | 512 | | |
| 513 | + | |
500 | 514 | | |
501 | 515 | | |
502 | 516 | | |
| |||
506 | 520 | | |
507 | 521 | | |
508 | 522 | | |
509 | | - | |
| 523 | + | |
510 | 524 | | |
511 | 525 | | |
512 | 526 | | |
| |||
515 | 529 | | |
516 | 530 | | |
517 | 531 | | |
| 532 | + | |
518 | 533 | | |
519 | 534 | | |
520 | 535 | | |
| |||
565 | 580 | | |
566 | 581 | | |
567 | 582 | | |
568 | | - | |
| 583 | + | |
569 | 584 | | |
570 | 585 | | |
| 586 | + | |
571 | 587 | | |
572 | 588 | | |
573 | 589 | | |
| |||
599 | 615 | | |
600 | 616 | | |
601 | 617 | | |
602 | | - | |
| 618 | + | |
603 | 619 | | |
604 | 620 | | |
| 621 | + | |
605 | 622 | | |
606 | 623 | | |
607 | 624 | | |
| |||
706 | 723 | | |
707 | 724 | | |
708 | 725 | | |
709 | | - | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
710 | 731 | | |
711 | 732 | | |
712 | 733 | | |
| |||
0 commit comments