add debug log level macros.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
1e0b34367b
commit
9361acadcb
2 changed files with 42 additions and 0 deletions
41
src/utils/debug.rs
Normal file
41
src/utils/debug.rs
Normal 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)+ );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
pub(crate) mod debug;
|
||||
pub(crate) mod error;
|
||||
|
||||
use std::{
|
||||
|
|
Loading…
Add table
Reference in a new issue