rustapi_core/
tracing_macros.rs

1//! Conditional tracing macros
2//!
3//! These macros wrap tracing calls to allow compilation without the `tracing` feature,
4//! reducing overhead for production deployments that don't need detailed logging.
5
6/// Log at error level, only when tracing feature is enabled
7#[cfg(feature = "tracing")]
8#[macro_export]
9macro_rules! trace_error {
10    ($($arg:tt)*) => {
11        tracing::error!($($arg)*)
12    };
13}
14
15/// Log at error level, no-op when tracing feature is disabled
16#[cfg(not(feature = "tracing"))]
17#[macro_export]
18macro_rules! trace_error {
19    ($($arg:tt)*) => {};
20}
21
22/// Log at warn level, only when tracing feature is enabled
23#[cfg(feature = "tracing")]
24#[macro_export]
25macro_rules! trace_warn {
26    ($($arg:tt)*) => {
27        tracing::warn!($($arg)*)
28    };
29}
30
31/// Log at warn level, no-op when tracing feature is disabled
32#[cfg(not(feature = "tracing"))]
33#[macro_export]
34macro_rules! trace_warn {
35    ($($arg:tt)*) => {};
36}
37
38/// Log at info level, only when tracing feature is enabled
39#[cfg(feature = "tracing")]
40#[macro_export]
41macro_rules! trace_info {
42    ($($arg:tt)*) => {
43        tracing::info!($($arg)*)
44    };
45}
46
47/// Log at info level, no-op when tracing feature is disabled
48#[cfg(not(feature = "tracing"))]
49#[macro_export]
50macro_rules! trace_info {
51    ($($arg:tt)*) => {};
52}
53
54/// Log at debug level, only when tracing feature is enabled
55#[cfg(feature = "tracing")]
56#[macro_export]
57macro_rules! trace_debug {
58    ($($arg:tt)*) => {
59        tracing::debug!($($arg)*)
60    };
61}
62
63/// Log at debug level, no-op when tracing feature is disabled
64#[cfg(not(feature = "tracing"))]
65#[macro_export]
66macro_rules! trace_debug {
67    ($($arg:tt)*) => {};
68}
69
70/// Log at trace level, only when tracing feature is enabled
71#[cfg(feature = "tracing")]
72#[macro_export]
73macro_rules! trace_trace {
74    ($($arg:tt)*) => {
75        tracing::trace!($($arg)*)
76    };
77}
78
79/// Log at trace level, no-op when tracing feature is disabled
80#[cfg(not(feature = "tracing"))]
81#[macro_export]
82macro_rules! trace_trace {
83    ($($arg:tt)*) => {};
84}