diff --git a/tracing-subscriber/src/fmt/fmt_subscriber.rs b/tracing-subscriber/src/fmt/fmt_subscriber.rs index 9887b711ff..bae2a2d795 100644 --- a/tracing-subscriber/src/fmt/fmt_subscriber.rs +++ b/tracing-subscriber/src/fmt/fmt_subscriber.rs @@ -284,6 +284,14 @@ impl Subscriber { } } + /// Disable ANSI terminal colors. Available even without the `ansi` crate feature. + pub fn disable_ansi(self) -> Self { + Subscriber { + is_ansi: false, + ..self + } + } + /// Sets whether to write errors from [`FormatEvent`] to the writer. /// Defaults to true. /// diff --git a/tracing-subscriber/src/fmt/mod.rs b/tracing-subscriber/src/fmt/mod.rs index ba5066d2ec..d47d611030 100644 --- a/tracing-subscriber/src/fmt/mod.rs +++ b/tracing-subscriber/src/fmt/mod.rs @@ -620,6 +620,14 @@ where } } + /// Disable ANSI terminal colors. Available even without the `ansi` crate feature. + pub fn disable_ansi(self) -> CollectorBuilder, F, W> { + CollectorBuilder { + inner: self.inner.disable_ansi(), + ..self + } + } + /// Sets whether to write errors from [`FormatEvent`] to the writer. /// Defaults to true. ///