add debug log level macros.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-04-19 20:48:47 -07:00 committed by June
parent 1e0b34367b
commit 9361acadcb
2 changed files with 42 additions and 0 deletions

41
src/utils/debug.rs Normal file
View file

@ -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)+ );
}
}
}

View file

@ -1,3 +1,4 @@
pub(crate) mod debug;
pub(crate) mod error; pub(crate) mod error;
use std::{ use std::{