mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 02:16:29 +03:00
feat: Log failed debug assertions in all configurations
Add `logged_debug_assert` macro logging a warning if a condition is not satisfied, before invoking
`debug_assert!`, and use this macro where `Context` is accessible (i.e. don't change function
signatures for now).
Follow-up to 0359481ba4.
This commit is contained in:
12
src/tools.rs
12
src/tools.rs
@@ -801,5 +801,17 @@ macro_rules! ensure_and_debug_assert_ne {
|
||||
};
|
||||
}
|
||||
|
||||
/// Logs a warning if a condition is not satisfied.
|
||||
/// In non-optimized builds, panics also if so.
|
||||
#[macro_export]
|
||||
macro_rules! logged_debug_assert {
|
||||
($ctx:expr, $cond:expr, $($arg:tt)*) => {
|
||||
if !$cond {
|
||||
warn!($ctx, $($arg)*);
|
||||
}
|
||||
debug_assert!($cond, $($arg)*);
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tools_tests;
|
||||
|
||||
Reference in New Issue
Block a user