Add documentation for init_logger_with_additional_layer

This commit is contained in:
Stypox
2025-06-12 12:09:55 +02:00
parent fc96ca8bba
commit 781baafbe4
2 changed files with 14 additions and 4 deletions

View File

@@ -1500,13 +1500,18 @@ pub fn init_rustc_env_logger(early_dcx: &EarlyDiagCtxt) {
/// This allows tools to enable rust logging without having to magically match rustc's
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose
/// the values directly rather than having to set an environment variable.
/// the logger config directly rather than having to set an environment variable.
pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
if let Err(error) = rustc_log::init_logger(cfg) {
early_dcx.early_fatal(error.to_string());
}
}
/// This allows tools to enable rust logging without having to magically match rustc's
/// tracing crate version. In contrast to `init_rustc_env_logger`, it allows you to
/// choose the logger config directly rather than having to set an environment variable.
/// Moreover, in contrast to `init_logger`, it allows you to add a custom tracing layer
/// via `build_subscriber`, for example `|| Registry::default().with(custom_layer)`.
pub fn init_logger_with_additional_layer<F, T>(
early_dcx: &EarlyDiagCtxt,
cfg: rustc_log::LoggerConfig,