Skip to main content

facet_diff/
tracing_macros.rs

1//! Tracing macros that compile to nothing when tracing is disabled.
2//!
3//! Tracing is enabled when either:
4//! - The `tracing` feature is enabled (for production use)
5//! - Running tests (`cfg(test)`) - tracing is always available in tests
6
7/// Emit an extremely verbose trace-level log message.
8/// This is for tracing that's too noisy even for trace level.
9/// Uncomment the tracing::trace! line below to enable.
10#[cfg(any(test, feature = "tracing"))]
11#[macro_export]
12macro_rules! trace_verbose {
13    ($($arg:tt)*) => {
14        // tracing::trace!($($arg)*);
15    };
16}
17
18/// Emit an extremely verbose trace-level log message (no-op version).
19#[cfg(not(any(test, feature = "tracing")))]
20#[macro_export]
21macro_rules! trace_verbose {
22    ($($arg:tt)*) => {};
23}
24
25/// Emit a trace-level log message.
26#[cfg(any(test, feature = "tracing"))]
27#[macro_export]
28macro_rules! trace {
29    ($($arg:tt)*) => {
30        tracing::trace!($($arg)*);
31    };
32}
33
34/// Emit a trace-level log message (no-op version).
35#[cfg(not(any(test, feature = "tracing")))]
36#[macro_export]
37macro_rules! trace {
38    ($($arg:tt)*) => {};
39}
40
41/// Emit a debug-level log message.
42#[cfg(any(test, feature = "tracing"))]
43#[macro_export]
44macro_rules! debug {
45    ($($arg:tt)*) => {
46        tracing::debug!($($arg)*);
47    };
48}
49
50/// Emit a debug-level log message (no-op version).
51#[cfg(not(any(test, feature = "tracing")))]
52#[macro_export]
53macro_rules! debug {
54    ($($arg:tt)*) => {};
55}