@@ -473,8 +473,7 @@ impl<S, F, C> Filtered<S, F, C> {
473473
474474 /// Mutably borrows the [`Filter`](crate::subscribe::Filter) used by this subscriber.
475475 ///
476- /// When this subscriber can be mutably borrowed, this may be used to mutate the filter.
477- /// Generally, this will primarily be used with the
476+ /// This method is primarily expected to be used with the
478477 /// [`reload::Handle::modify`](crate::reload::Handle::modify) method.
479478 ///
480479 /// # Examples
@@ -499,6 +498,46 @@ impl<S, F, C> Filtered<S, F, C> {
499498 pub fn filter_mut ( & mut self ) -> & mut F {
500499 & mut self . filter
501500 }
501+
502+ /// Borrows the inner [subscriber] wrapped by this `Filtered` subscriber.
503+ ///
504+ /// [subscriber]: Subscribe
505+ pub fn inner ( & self ) -> & S {
506+ & self . subscriber
507+ }
508+
509+ /// Mutably borrows the inner [subscriber] wrapped by this `Filtered` subscriber.
510+ ///
511+ /// This method is primarily expected to be used with the
512+ /// [`reload::Handle::modify`](crate::reload::Handle::modify) method.
513+ ///
514+ /// # Examples
515+ ///
516+ /// ```
517+ /// # use tracing::info;
518+ /// # use tracing_subscriber::{filter,fmt,reload,Registry,prelude::*};
519+ /// # fn non_blocking<T: std::io::Write>(writer: T) -> (fn() -> std::io::Stdout) {
520+ /// # std::io::stdout
521+ /// # }
522+ /// # fn main() {
523+ /// let filtered_subscriber = fmt::subscriber().with_writer(non_blocking(std::io::stderr())).with_filter(filter::LevelFilter::INFO);
524+ /// let (filtered_subscriber, reload_handle) = reload::Subscriber::new(filtered_subscriber);
525+ /// #
526+ /// # // specifying the Registry type is required
527+ /// # let _: &reload::Handle<filter::Filtered<fmt::Subscriber<Registry, _, _, fn() -> std::io::Stdout>,
528+ /// # filter::LevelFilter, Registry>>
529+ /// # = &reload_handle;
530+ /// #
531+ /// info!("This will be logged to stderr");
532+ /// reload_handle.modify(|subscriber| *subscriber.inner_mut().writer_mut() = non_blocking(std::io::stdout()));
533+ /// info!("This will be logged to stdout");
534+ /// # }
535+ /// ```
536+ ///
537+ /// [subscriber]: Subscribe
538+ pub fn inner_mut ( & mut self ) -> & mut S {
539+ & mut self . subscriber
540+ }
502541}
503542
504543impl < C , S , F > Subscribe < C > for Filtered < S , F , C >
0 commit comments