Skip to main content

acorn/util/
macros.rs

1//! Macros for logging and other utilities
2
3/// Logging macro for failures
4#[macro_export]
5macro_rules! fail {
6    ($msg:literal, $($rest:tt)*) => {
7        tracing::error!(
8            "{}",
9            format!(
10                "=> {} {}",
11                $crate::util::Label::fail(),
12                format!($msg, $($rest)*)
13            )
14        );
15    };
16    ($msg:literal) => {
17        tracing::error!("{}", format!("=> {} {}", $crate::util::Label::fail(), $msg));
18    };
19    ($($args:tt)*) => {
20        tracing::error!($($args)*);
21    };
22}
23/// Logging macro for skipped operations
24#[macro_export]
25macro_rules! skip {
26    ($msg:literal, $($rest:tt)*) => {
27        tracing::warn!(
28            "{}",
29            format!(
30                "=> {} {}",
31                $crate::util::Label::skip(),
32                format!($msg, $($rest)*)
33            )
34        );
35    };
36    ($msg:literal) => {
37        tracing::warn!("{}", format!("=> {} {}", $crate::util::Label::skip(), $msg));
38    };
39    ($($args:tt)*) => {
40        tracing::warn!($($args)*);
41    };
42}