diff --git a/src/utils/debug.rs b/src/utils/debug.rs new file mode 100644 index 00000000..6c1093a0 --- /dev/null +++ b/src/utils/debug.rs @@ -0,0 +1,41 @@ +/// Log message at the ERROR level in debug-mode (when debug-assertions are +/// enabled). In release mode it becomes DEBUG level, and possibly subject to +/// elision. +#[macro_export] +macro_rules! debug_error { + ( $($x:tt)+ ) => { + if cfg!(debug_assertions) { + error!( $($x)+ ); + } else { + debug!( $($x)+ ); + } + } +} + +/// Log message at the WARN level in debug-mode (when debug-assertions are +/// enabled). In release mode it becomes DEBUG level, and possibly subject to +/// elision. +#[macro_export] +macro_rules! debug_warn { + ( $($x:tt)+ ) => { + if cfg!(debug_assertions) { + warn!( $($x)+ ); + } else { + debug!( $($x)+ ); + } + } +} + +/// Log message at the INFO level in debug-mode (when debug-assertions are +/// enabled). In release mode it becomes DEBUG level, and possibly subject to +/// elision. +#[macro_export] +macro_rules! debug_info { + ( $($x:tt)+ ) => { + if cfg!(debug_assertions) { + info!( $($x)+ ); + } else { + debug!( $($x)+ ); + } + } +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 225c2200..248ff144 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,3 +1,4 @@ +pub(crate) mod debug; pub(crate) mod error; use std::{