From 1f51b5310f85ad28f2d00ce223c59ff0be9619d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 3 Sep 2024 09:36:28 +0100 Subject: [PATCH] feat: support DENO_LOG env var instead of RUST_LOG (#25356) Instead of `RUST_LOG` env var, we now support `DENO_LOG` env var. This is done to be able to set a setting specific to `deno` that wouldn't impact other binaries written in Rust. Ref https://github.com/denoland/deno/issues/10558#issuecomment-2324300211 --- cli/util/logger.rs | 6 ++++-- tests/integration/run_tests.rs | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cli/util/logger.rs b/cli/util/logger.rs index d64e9a707b..cdc89411fe 100644 --- a/cli/util/logger.rs +++ b/cli/util/logger.rs @@ -41,8 +41,10 @@ impl log::Log for CliLogger { pub fn init(maybe_level: Option) { let log_level = maybe_level.unwrap_or(log::Level::Info); let logger = env_logger::Builder::from_env( - env_logger::Env::default() - .default_filter_or(log_level.to_level_filter().to_string()), + env_logger::Env::new() + // Use `DENO_LOG` and `DENO_LOG_STYLE` instead of `RUST_` prefix + .filter_or("DENO_LOG", log_level.to_level_filter().to_string()) + .write_style("DENO_LOG_STYLE"), ) // https://github.com/denoland/deno/issues/6641 .filter_module("rustyline", log::LevelFilter::Off) diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index efa2e6c850..360ff4d774 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -2499,8 +2499,8 @@ fn should_not_panic_on_undefined_deno_dir_and_home_environment_variables() { } #[test] -fn rust_log() { - // Without RUST_LOG the stderr is empty. +fn deno_log() { + // Without DENO_LOG the stderr is empty. let output = util::deno_cmd() .current_dir(util::testdata_path()) .arg("run") @@ -2513,12 +2513,12 @@ fn rust_log() { assert!(output.status.success()); assert!(output.stderr.is_empty()); - // With RUST_LOG the stderr is not empty. + // With DENO_LOG the stderr is not empty. let output = util::deno_cmd() .current_dir(util::testdata_path()) .arg("run") .arg("run/001_hello.js") - .env("RUST_LOG", "debug") + .env("DENO_LOG", "debug") .stderr_piped() .spawn() .unwrap()