From 57b8d6620ce212b12a2cef3c16fa81430dce8110 Mon Sep 17 00:00:00 2001 From: Eloi DEMOLIS Date: Thu, 10 Oct 2024 11:22:20 +0200 Subject: [PATCH] Elide allocation and formating of opt-out logs Signed-off-by: Eloi DEMOLIS --- command/src/logging/logs.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/command/src/logging/logs.rs b/command/src/logging/logs.rs index 887ce1282..d0b231ebb 100644 --- a/command/src/logging/logs.rs +++ b/command/src/logging/logs.rs @@ -572,13 +572,16 @@ pub fn parse_logging_spec(spec: &str) -> (Vec, Vec (num, None), - Err(_) => (LogLevelFilter::max(), Some(part0)), + Err(_) => { + errors.push(LogSpecParseError::InvalidLogLevel(s.to_string())); + (LogLevelFilter::max(), None) + } } } (Some(part0), Some(""), None) => (LogLevelFilter::max(), Some(part0)), (Some(part0), Some(part1), None) => match part1.parse() { Ok(num) => (num, Some(part0)), - _ => { + Err(_) => { errors.push(LogSpecParseError::InvalidLogLevel(s.to_string())); continue; } @@ -945,7 +948,7 @@ macro_rules! debug { #[cfg(any(debug_assertions, feature = "logs-debug", feature = "logs-trace"))] $crate::_log!($crate::logging::LogLevel::Debug, concat!("{}\t", $format), module_path!() $(, $args)*); #[cfg(not(any(debug_assertions, feature = "logs-trace")))] - {$( let _ = $args; )*} + if false {$( let _ = $args; )*} }}; } @@ -956,7 +959,7 @@ macro_rules! trace { #[cfg(any(debug_assertions, feature = "logs-trace"))] $crate::_log!($crate::logging::LogLevel::Trace, concat!("{}\t", $format), module_path!() $(, $args)*); #[cfg(not(any(debug_assertions, feature = "logs-trace")))] - {$( let _ = $args; )*} + if false {$( let _ = $args; )*} }}; }