-
Notifications
You must be signed in to change notification settings - Fork 676
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
subscriber: update pretty formatter for no ansi #1240
Commits on Mar 11, 2021
-
subscriber: update pretty formatter for no ansi
## Background Currently, when the `Pretty` event formatter is being used, it does not change its output when the `with_ansi` flag is set to false by the `CollectorBuilder`. ## Overview While this formatter is generally used in situations such as local development, where ANSI escape codes are more often acceptable, there are some situations in which this can lead to mangled output. This commit makes some minor changes to account for this `ansi` flag when formatting events using `Pretty`. Becuase ANSI codes were previously used to imply the event level using colors, this commit additionally modifies `Pretty` so that it respects `display_level` when formatting an event. ## Changes * Changes to `<Format<Pretty, T> as FormatEvent<C, N>>::format_event` * Implement `LevelNames` for `Pretty`, copying `Full`'s implementation. * Add a `PrettyVisitor::ansi` boolean flag, used in its `Visit` implementation. * Add a new `PrettyVisitor::with_ansi` builder pattern method to facilitate this. ## Out of Scope One detail worth nothing is that this does not solve the problem of *fields* being formatted without ANSI codes. Configuring a subscriber using this snippet would still lead to bolded fields in parent spans. ```rust tracing_subscriber::fmt() .pretty() .with_ansi(false) .with_level(false) .with_max_level(tracing::Level::TRACE) .init(); ``` This can be worked around by using a different field formatter, via `.fmt_fields(tracing_subscriber::fmt::format::DefaultFields::new())` in the short-term. In the long-term, tokio-rs#658 is worth investigating further. Refs: tokio-rs#658
katelyn martin committedMar 11, 2021 Configuration menu - View commit details
-
Copy full SHA for 0788fc3 - Browse repository at this point
Copy the full SHA 0788fc3View commit details -
subscriber: add missing cfg attribute
katelyn martin committedMar 11, 2021 Configuration menu - View commit details
-
Copy full SHA for 9c837ac - Browse repository at this point
Copy the full SHA 9c837acView commit details -
subscriber: add inherent
bold
method (review)Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Configuration menu - View commit details
-
Copy full SHA for 2025f5e - Browse repository at this point
Copy the full SHA 2025f5eView commit details -
subscriber: add new
PrettyFields
struct (review)Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Configuration menu - View commit details
-
Copy full SHA for 603fbff - Browse repository at this point
Copy the full SHA 603fbffView commit details -
subscriber: document ansi behavior of
pretty()
(review)Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Configuration menu - View commit details
-
Copy full SHA for 80a9396 - Browse repository at this point
Copy the full SHA 80a9396View commit details -
subscriber: clarify comment on ansi codes (review)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Configuration menu - View commit details
-
Copy full SHA for 45f21dc - Browse repository at this point
Copy the full SHA 45f21dcView commit details -
subscriber: add missing whitespace (review)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Configuration menu - View commit details
-
Copy full SHA for c017573 - Browse repository at this point
Copy the full SHA c017573View commit details -
subscriber: move
PrettyFields
, remove_private
(review)Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Configuration menu - View commit details
-
Copy full SHA for 779f53b - Browse repository at this point
Copy the full SHA 779f53bView commit details -
subscriber: katie did an oopsie
katelyn martin committedMar 11, 2021 Configuration menu - View commit details
-
Copy full SHA for 5f6cb42 - Browse repository at this point
Copy the full SHA 5f6cb42View commit details -
subscriber: katie did *two* oopsies
katelyn martin committedMar 11, 2021 Configuration menu - View commit details
-
Copy full SHA for e990936 - Browse repository at this point
Copy the full SHA e990936View commit details -
subsciber: fix doc test (three oopsies)
katelyn martin committedMar 11, 2021 Configuration menu - View commit details
-
Copy full SHA for 2d23a01 - Browse repository at this point
Copy the full SHA 2d23a01View commit details