@@ -43,8 +43,7 @@ use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter};
43
43
use tracing_subscriber:: fmt:: FmtContext ;
44
44
use tracing_subscriber:: fmt:: format:: { self , FormatEvent , FormatFields } ;
45
45
use 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 } ;
48
47
49
48
/// The values of all the environment variables that matter for configuring a logger.
50
49
/// Errors are explicitly preserved so that we can share error handling.
@@ -77,6 +76,11 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {
77
76
init_logger_with_additional_layer ( cfg, || Registry :: default ( ) )
78
77
}
79
78
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`.
80
84
pub trait BuildSubscriberRet :
81
85
tracing:: Subscriber + for < ' span > tracing_subscriber:: registry:: LookupSpan < ' span > + Send + Sync
82
86
{
89
93
}
90
94
91
95
/// 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)`.
93
98
pub fn init_logger_with_additional_layer < F , T > (
94
99
cfg : LoggerConfig ,
95
100
build_subscriber : F ,
0 commit comments