From 9a9b7cd7b9e905bf83d2cd0277dbc6a0c5d12594 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 30 Dec 2023 15:01:32 +0100 Subject: [PATCH] Promote debug assertion failures to warnings --- CHANGELOG.md | 3 +++ src/debug.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96cf4070..0c27dbda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,9 @@ state is to list breaking changes. libraries that link against a different version of `raw_window_handle` than the one used by NIH-plug itself by simply wrapping around `ParentWindowHandle`. +- `nih_debug_assert*!()` failures are now promoted to a warning instead of a + debug message. This makes the non-fatal debug assertion failures easier to + spot. ## [2023-12-30] diff --git a/src/debug.rs b/src/debug.rs index 86dca53c..ff515b3c 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -94,7 +94,7 @@ macro_rules! nih_debug_assert { if cfg!(test) { debug_assert!($cond); } else if cfg!(debug_assertions) && !$cond { - $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond)))); + $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($cond)))); } ); ($cond:expr, $format:expr $(, $($args:tt)*)?) => ( @@ -102,7 +102,7 @@ macro_rules! nih_debug_assert { if cfg!(test) { debug_assert!($cond, $format, $($($args)*)?); } else if cfg!(debug_assertions) && !$cond { - $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($cond), ", ", $format), $($($args)*)?)); + $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($cond), ", ", $format), $($($args)*)?)); } ); } @@ -117,14 +117,14 @@ macro_rules! nih_debug_assert_failure { if cfg!(test) { debug_assert!(false, "Debug assertion failed"); } else if cfg!(debug_assertions) { - $crate::util::permit_alloc(|| $crate::log::debug!("Debug assertion failed")); + $crate::util::permit_alloc(|| $crate::log::warn!("Debug assertion failed")); } ); ($format:expr $(, $($args:tt)*)?) => ( if cfg!(test) { debug_assert!(false, concat!("Debug assertion failed: ", $format), $($($args)*)?); } else if cfg!(debug_assertions) { - $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", $format), $($($args)*)?)); + $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", $format), $($($args)*)?)); } ); } @@ -140,7 +140,7 @@ macro_rules! nih_debug_assert_eq { if cfg!(test) { debug_assert_eq!($left, $right); } else if cfg!(debug_assertions) && $left != $right { - $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right)))); + $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right)))); } ); ($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => ( @@ -148,7 +148,7 @@ macro_rules! nih_debug_assert_eq { if cfg!(test) { debug_assert_eq!($left, $right, $format, $($($args)*)?); } else if cfg!(debug_assertions) && $left != $right { - $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right), ", ", $format), $($($args)*)?)); + $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right), ", ", $format), $($($args)*)?)); } ); } @@ -164,7 +164,7 @@ macro_rules! nih_debug_assert_ne { if cfg!(test) { debug_assert_ne!($left, $right); } else if cfg!(debug_assertions) && $left == $right { - $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right)))); + $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right)))); } ); ($left:expr, $right:expr, $format:expr $(, $($args:tt)*)?) => ( @@ -172,7 +172,7 @@ macro_rules! nih_debug_assert_ne { if cfg!(test) { debug_assert_ne!($left, $right, $format, $($($args)*)?); } else if cfg!(debug_assertions) && $left == $right { - $crate::util::permit_alloc(|| $crate::log::debug!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right), ", ", $format), $($($args)*)?)); + $crate::util::permit_alloc(|| $crate::log::warn!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right), ", ", $format), $($($args)*)?)); } ); }