Skip to content

Commit

Permalink
Merge pull request #1139 from sozu-proxy/devel/edemolis/fix/elide-dea…
Browse files Browse the repository at this point in the history
…d-logs

Elide allocation and formating of opt-out logs
  • Loading branch information
FlorentinDUBOIS authored Oct 10, 2024
2 parents f79544e + 57b8d66 commit ac42dc0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions command/src/logging/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,16 @@ pub fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Vec<LogSpecParseErr
// treat that as a global fallback
match part0.parse() {
Ok(num) => (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;
}
Expand Down Expand Up @@ -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; )*}
}};
}

Expand All @@ -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; )*}
}};
}

Expand Down

0 comments on commit ac42dc0

Please sign in to comment.