Skip to content

Commit 801bff0

Browse files
author
katelyn martin
committed
subscriber: document ansi behavior of pretty()
1 parent eadd3fd commit 801bff0

File tree

1 file changed

+15
-0
lines changed
  • tracing-subscriber/src/fmt/format

1 file changed

+15
-0
lines changed

tracing-subscriber/src/fmt/format/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ impl<F, T> Format<F, T> {
294294
/// See [`Pretty`].
295295
///
296296
/// Note that this requires the "ansi" feature to be enabled.
297+
///
298+
/// # Options
299+
///
300+
/// [`Format::with_ansi`] can be used to disable ANSI formatting in event formatting. However,
301+
/// a field formatter must be manually provided to avoid ANSI in the formatting of parent
302+
/// spans, like so:
303+
///
304+
/// ```
305+
/// tracing_subscriber::fmt()
306+
/// .pretty()
307+
/// .with_ansi(false)
308+
/// .fmt_fields(format::PrettyFields::new().with_ansi(false))
309+
/// // ... other settings ...
310+
/// .init();
311+
/// ```
297312
#[cfg(feature = "ansi")]
298313
#[cfg_attr(docsrs, doc(cfg(feature = "ansi")))]
299314
pub fn pretty(self) -> Format<Pretty, T> {

0 commit comments

Comments
 (0)