diff options
| author | bors <bors@rust-lang.org> | 2023-11-15 08:03:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-15 08:03:07 +0000 |
| commit | ee85f7fc48bf3f21e212d46b4a2be12f307abea5 (patch) | |
| tree | a00166aabfc2e2ca31c8dad08854ce7dad85f543 /compiler/rustc_driver_impl/src | |
| parent | 698fcc8219e6dd690b148a23af10a0e5747621fe (diff) | |
| parent | 86e5d36c19d2cd53f55e8a2e0b8589f756ff7d66 (diff) | |
| download | rust-ee85f7fc48bf3f21e212d46b4a2be12f307abea5.tar.gz rust-ee85f7fc48bf3f21e212d46b4a2be12f307abea5.zip | |
Auto merge of #117814 - RalfJung:rustc-logger-without-set-var, r=TaKO8Ki
rustc_log: provide a way to init logging based on the values, not names, of the env vars Miri wants to affect how rustc does logging. So far this required setting environment variables before calling `rustc_driver::init_rustc_env_logger`. However, `set_var` is a function one should really [avoid calling](https://github.com/rust-lang/rust/issues/90308), so this adds the necessary APIs to rustc such that Miri can just pass it the *values* of all the log-relevant environment variables, rather than having to change the global environment.
Diffstat (limited to 'compiler/rustc_driver_impl/src')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 7905a0e3924..17a53aafe9a 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1520,14 +1520,14 @@ fn report_ice( /// This allows tools to enable rust logging without having to magically match rustc's /// tracing crate version. pub fn init_rustc_env_logger(handler: &EarlyErrorHandler) { - init_env_logger(handler, "RUSTC_LOG"); + init_logger(handler, rustc_log::LoggerConfig::from_env("RUSTC_LOG")); } /// 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 an env var -/// other than `RUSTC_LOG`. -pub fn init_env_logger(handler: &EarlyErrorHandler, env: &str) { - if let Err(error) = rustc_log::init_env_logger(env) { +/// 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. +pub fn init_logger(handler: &EarlyErrorHandler, cfg: rustc_log::LoggerConfig) { + if let Err(error) = rustc_log::init_logger(cfg) { handler.early_error(error.to_string()); } } |
