aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/debug.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/debug.rs')
-rw-r--r--mingling_core/src/debug.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/mingling_core/src/debug.rs b/mingling_core/src/debug.rs
index 9fd553c..f92cd3d 100644
--- a/mingling_core/src/debug.rs
+++ b/mingling_core/src/debug.rs
@@ -1,4 +1,6 @@
#[macro_export]
+/// A macro that only executes the given expressions when the `debug` feature is enabled.
+/// If the feature is not enabled, the expressions are compiled away.
macro_rules! only_debug {
($($expr:expr);* $(;)?) => {
#[cfg(feature = "debug")]
@@ -9,6 +11,8 @@ macro_rules! only_debug {
}
#[macro_export]
+/// Logs a message at the trace level, but only if the `debug` feature is enabled.
+/// Delegates to `log::trace!` internally.
macro_rules! trace {
($($arg:tt)*) => {
$crate::only_debug! {
@@ -18,6 +22,8 @@ macro_rules! trace {
}
#[macro_export]
+/// Logs a message at the debug level, but only if the `debug` feature is enabled.
+/// Delegates to `log::debug!` internally.
macro_rules! debug {
($($arg:tt)*) => {
$crate::only_debug! {
@@ -27,6 +33,8 @@ macro_rules! debug {
}
#[macro_export]
+/// Logs a message at the info level, but only if the `debug` feature is enabled.
+/// Delegates to `log::info!` internally.
macro_rules! info {
($($arg:tt)*) => {
$crate::only_debug! {
@@ -36,6 +44,8 @@ macro_rules! info {
}
#[macro_export]
+/// Logs a message at the warn level, but only if the `debug` feature is enabled.
+/// Delegates to `log::warn!` internally.
macro_rules! warn {
($($arg:tt)*) => {
$crate::only_debug! {
@@ -45,6 +55,8 @@ macro_rules! warn {
}
#[macro_export]
+/// Logs a message at the error level, but only if the `debug` feature is enabled.
+/// Delegates to `log::error!` internally.
macro_rules! error {
($($arg:tt)*) => {
$crate::only_debug! {