From caa42505a76be1079207a3ed5a3e2bb2aa4899f5 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 1 Mar 2024 14:02:59 +0200 Subject: [PATCH 1/3] ci: Disable Rust log for release builds via feature Alternative to #1688 --- neqo-common/Cargo.toml | 2 +- neqo-common/src/log.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/neqo-common/Cargo.toml b/neqo-common/Cargo.toml index 7017ff9600..84a72e47af 100644 --- a/neqo-common/Cargo.toml +++ b/neqo-common/Cargo.toml @@ -13,7 +13,7 @@ license.workspace = true # Sync with https://searchfox.org/mozilla-central/source/Cargo.lock 2024-02-08 enum-map = "2.7" env_logger = { version = "0.10", default-features = false } -log = { version = "0.4", default-features = false } +log = { version = "0.4", default-features = false, features = ["release_max_level_off"] } qlog = "0.12" quinn-udp = { git = "https://github.com/quinn-rs/quinn/", rev = "a947962131aba8a6521253d03cc948b20098a2d6", optional = true } time = { version = "0.3", features = ["formatting"] } diff --git a/neqo-common/src/log.rs b/neqo-common/src/log.rs index 1b181de56b..dfa931162d 100644 --- a/neqo-common/src/log.rs +++ b/neqo-common/src/log.rs @@ -18,7 +18,7 @@ use env_logger::Builder; macro_rules! do_log { (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({ let lvl = $lvl; - if lvl <= ::log::max_level() { + if lvl <= ::log::STATIC_MAX_LEVEL && lvl <= ::log::max_level() { ::log::logger().log( &::log::Record::builder() .args(format_args!($($arg)+)) From bab5ae7958ef3a6dced92d7572b4920e37003aa3 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 1 Mar 2024 15:16:15 +0200 Subject: [PATCH 2/3] Skip more things when log is off --- neqo-common/src/log.rs | 5 +++++ neqo-transport/src/connection/dump.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/neqo-common/src/log.rs b/neqo-common/src/log.rs index dfa931162d..c5b89be8a6 100644 --- a/neqo-common/src/log.rs +++ b/neqo-common/src/log.rs @@ -52,6 +52,11 @@ fn since_start() -> Duration { pub fn init() { static INIT_ONCE: Once = Once::new(); + + if ::log::STATIC_MAX_LEVEL == ::log::LevelFilter::Off { + return; + } + INIT_ONCE.call_once(|| { let mut builder = Builder::from_env("RUST_LOG"); builder.format(|buf, record| { diff --git a/neqo-transport/src/connection/dump.rs b/neqo-transport/src/connection/dump.rs index 8811e4f05f..8a4f34dbb8 100644 --- a/neqo-transport/src/connection/dump.rs +++ b/neqo-transport/src/connection/dump.rs @@ -27,7 +27,7 @@ pub fn dump_packet( pn: PacketNumber, payload: &[u8], ) { - if !log::log_enabled!(log::Level::Debug) { + if log::STATIC_MAX_LEVEL == log::LevelFilter::Off || !log::log_enabled!(log::Level::Debug) { return; } From 8d89a88e37b6329eb2c9d2f24dfdd7bb8770c798 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Mon, 11 Mar 2024 18:43:19 +0200 Subject: [PATCH 3/3] Don't set `features = ["release_max_level_off"]`, but leave rest in place --- neqo-common/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neqo-common/Cargo.toml b/neqo-common/Cargo.toml index 8a0ab20ddb..5d4d3d0d26 100644 --- a/neqo-common/Cargo.toml +++ b/neqo-common/Cargo.toml @@ -16,7 +16,7 @@ workspace = true # Sync with https://searchfox.org/mozilla-central/source/Cargo.lock 2024-02-08 enum-map = { version = "2.7", default-features = false } env_logger = { version = "0.10", default-features = false } -log = { version = "0.4", default-features = false, features = ["release_max_level_off"] } +log = { version = "0.4", default-features = false } qlog = { version = "0.12", default-features = false } quinn-udp = { git = "https://github.com/quinn-rs/quinn/", rev = "a947962131aba8a6521253d03cc948b20098a2d6", optional = true } time = { version = "0.3", default-features = false, features = ["formatting"] }