@@ -43,8 +43,7 @@ use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter};
4343use tracing_subscriber:: fmt:: FmtContext ;
4444use tracing_subscriber:: fmt:: format:: { self , FormatEvent , FormatFields } ;
4545use tracing_subscriber:: layer:: SubscriberExt ;
46- // Re-export tracing_subscriber items so rustc_driver_impl doesn't need to depend on it.
47- pub use tracing_subscriber:: { Layer , Registry } ;
46+ use tracing_subscriber:: { Layer , Registry } ;
4847
4948/// The values of all the environment variables that matter for configuring a logger.
5049/// Errors are explicitly preserved so that we can share error handling.
@@ -77,6 +76,11 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {
7776 init_logger_with_additional_layer ( cfg, || Registry :: default ( ) )
7877}
7978
79+ /// Trait alias for the complex return type of `build_subscriber` in
80+ /// [init_logger_with_additional_layer]. A [Registry] with any composition of [tracing::Subscriber]s
81+ /// (e.g. `Registry::default().with(custom_layer)`) should be compatible with this type.
82+ /// Having an alias is also useful so rustc_driver_impl does not need to explicitly depend on
83+ /// `tracing_subscriber`.
8084pub trait BuildSubscriberRet :
8185 tracing:: Subscriber + for < ' span > tracing_subscriber:: registry:: LookupSpan < ' span > + Send + Sync
8286{
8993}
9094
9195/// Initialize the logger with the given values for the filter, coloring, and other options env variables.
92- /// Additionally add a custom layer to collect logging and tracing events.
96+ /// Additionally add a custom layer to collect logging and tracing events via `build_subscriber`,
97+ /// for example: `|| Registry::default().with(custom_layer)`.
9398pub fn init_logger_with_additional_layer < F , T > (
9499 cfg : LoggerConfig ,
95100 build_subscriber : F ,
0 commit comments