|
| 1 | +// For completeness, wrappers around all of tracing's public logging and span macros are provided, |
| 2 | +// even if they are not used at the present time. |
| 3 | +#![allow(unused_macros)] |
| 4 | + |
| 5 | +#[cfg(all(not(hyper_unstable_tracing), feature = "tracing"))] |
| 6 | +compile_error!( |
| 7 | + "\ |
| 8 | + The `tracing` feature is unstable, and requires the \ |
| 9 | + `RUSTFLAGS='--cfg hyper_unstable_tracing'` environment variable to be set.\ |
| 10 | +" |
| 11 | +); |
| 12 | + |
| 13 | +macro_rules! debug { |
| 14 | + ($($arg:tt)+) => { |
| 15 | + #[cfg(feature = "tracing")] |
| 16 | + { |
| 17 | + tracing::debug!($($arg)+); |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +macro_rules! debug_span { |
| 23 | + ($($arg:tt)*) => { |
| 24 | + { |
| 25 | + #[cfg(feature = "tracing")] |
| 26 | + { |
| 27 | + let _span = tracing::debug_span!($($arg)+); |
| 28 | + _span.entered() |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +macro_rules! error { |
| 35 | + ($($arg:tt)*) => { |
| 36 | + #[cfg(feature = "tracing")] |
| 37 | + { |
| 38 | + tracing::error!($($arg)+); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +macro_rules! error_span { |
| 44 | + ($($arg:tt)*) => { |
| 45 | + { |
| 46 | + #[cfg(feature = "tracing")] |
| 47 | + { |
| 48 | + let _span = tracing::error_span!($($arg)+); |
| 49 | + _span.entered() |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +macro_rules! info { |
| 56 | + ($($arg:tt)*) => { |
| 57 | + #[cfg(feature = "tracing")] |
| 58 | + { |
| 59 | + tracing::info!($($arg)+); |
| 60 | + } |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +macro_rules! info_span { |
| 65 | + ($($arg:tt)*) => { |
| 66 | + { |
| 67 | + #[cfg(feature = "tracing")] |
| 68 | + { |
| 69 | + let _span = tracing::info_span!($($arg)+); |
| 70 | + _span.entered() |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +macro_rules! trace { |
| 77 | + ($($arg:tt)*) => { |
| 78 | + #[cfg(feature = "tracing")] |
| 79 | + { |
| 80 | + tracing::trace!($($arg)+); |
| 81 | + } |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +macro_rules! trace_span { |
| 86 | + ($($arg:tt)*) => { |
| 87 | + { |
| 88 | + #[cfg(feature = "tracing")] |
| 89 | + { |
| 90 | + let _span = tracing::trace_span!($($arg)+); |
| 91 | + _span.entered() |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +macro_rules! span { |
| 98 | + ($($arg:tt)*) => { |
| 99 | + { |
| 100 | + #[cfg(feature = "tracing")] |
| 101 | + { |
| 102 | + let _span = tracing::span!($($arg)+); |
| 103 | + _span.entered() |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | +macro_rules! warn { |
| 110 | + ($($arg:tt)*) => { |
| 111 | + #[cfg(feature = "tracing")] |
| 112 | + { |
| 113 | + tracing::warn!($($arg)+); |
| 114 | + } |
| 115 | + } |
| 116 | +} |
| 117 | + |
| 118 | +macro_rules! warn_span { |
| 119 | + ($($arg:tt)*) => { |
| 120 | + { |
| 121 | + #[cfg(feature = "tracing")] |
| 122 | + { |
| 123 | + let _span = tracing::warn_span!($($arg)+); |
| 124 | + _span.entered() |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | +} |
0 commit comments