Make rustdoc share the logger initialization routine with rustc.

This commit is contained in:
Oliver Scherer 2020-07-25 15:50:51 +02:00
parent 64296ec698
commit 208f973d1f
2 changed files with 11 additions and 4 deletions

View File

@ -1224,11 +1224,18 @@ pub fn install_ice_hook() {
}
/// This allows tools to enable rust logging without having to magically match rustc's
/// log crate version
/// log crate version.
pub fn init_rustc_env_logger() {
init_env_logger("RUSTC_LOG")
}
/// This allows tools to enable rust logging without having to magically match rustc's
/// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
/// other than `RUSTC_LOG`.
pub fn init_env_logger(env: &str) {
let builder = tracing_subscriber::FmtSubscriber::builder();
let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env("RUSTC_LOG"));
let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env(env));
builder.init()
}

View File

@ -14,7 +14,6 @@
#![feature(never_type)]
#![recursion_limit = "256"]
extern crate env_logger;
#[macro_use]
extern crate lazy_static;
extern crate rustc_ast;
@ -90,7 +89,8 @@ pub fn main() {
};
rustc_driver::set_sigpipe_handler();
rustc_driver::install_ice_hook();
env_logger::init_from_env("RUSTDOC_LOG");
rustc_driver::init_env_logger("RUSTDOC_LOG");
let res = std::thread::Builder::new()
.stack_size(thread_stack_size)
.spawn(move || get_args().map(|args| main_args(&args)).unwrap_or(1))