@@ -157,6 +157,52 @@ impl<C, N, E, W> Subscriber<C, N, E, W> {
157157 }
158158 }
159159
160+ /// Borrows the underlying [`MakeWriter`] for this subscriber.
161+ pub fn writer ( & self ) -> & W {
162+ & self . make_writer
163+ }
164+
165+ /// Mutably borrows the underlying [`MakeWriter`] for this subscriber.
166+ ///
167+ /// When this subscriber can be mutably borrowed, this may be used to mutate the writer.
168+ /// Generally, this will primarily be used with the
169+ /// [`reload::Handle::modify`](crate::reload::Handle::modify) method.
170+ ///
171+ /// # Examples
172+ ///
173+ /// ```
174+ /// # use tracing::info;
175+ /// # use tracing_subscriber::{fmt,reload,Registry,prelude::*};
176+ /// # fn non_blocking<T: std::io::Write>(writer: T) -> (fn() -> std::io::Stdout) {
177+ /// # std::io::stdout
178+ /// # }
179+ /// # fn main() {
180+ /// let subscriber = fmt::subscriber().with_writer(non_blocking(std::io::stderr()));
181+ /// let (subscriber, reload_handle) = reload::Subscriber::new(subscriber);
182+ /// #
183+ /// # // specifying the Registry type is required
184+ /// # let _: &reload::Handle<fmt::Subscriber<Registry, _, _, _>> = &reload_handle;
185+ /// #
186+ /// info!("This will be logged to stderr");
187+ /// reload_handle.modify(|subscriber| *subscriber.writer_mut() = non_blocking(std::io::stdout()));
188+ /// info!("This will be logged to stdout");
189+ /// # }
190+ /// ```
191+ pub fn writer_mut ( & mut self ) -> & mut W {
192+ & mut self . make_writer
193+ }
194+
195+ /// Changes whether this should use ansi colors.
196+ ///
197+ /// Generally, this will primarily be used with the
198+ /// [`reload::Handle::modify`](crate::reload::Handle::modify) method when changing
199+ /// the writer.
200+ #[ cfg( feature = "ansi" ) ]
201+ #[ cfg_attr( docsrs, doc( cfg( feature = "ansi" ) ) ) ]
202+ pub fn set_ansi ( & mut self , ansi : bool ) {
203+ self . is_ansi = ansi;
204+ }
205+
160206 /// Configures the subscriber to support [`libtest`'s output capturing][capturing] when used in
161207 /// unit tests.
162208 ///
0 commit comments