1#[allow(unused_macros)]
2#[macro_export]
3macro_rules! debug {
4 ($($arg:tt)+) => {
5 #[cfg(feature = "tracing")]
6 {
7 tracing::debug!($($arg)+);
8 }
9 };
10}
11
12#[allow(unused_macros)]
13#[macro_export]
14macro_rules! debug_span {
15 ($($arg:tt)*) => {
16 {
17 #[cfg(feature = "tracing")]
18 {
19 let _span = tracing::debug_span!($($arg)+);
20 _span.entered()
21 }
22 }
23 }
24}
25
26#[allow(unused_macros)]
27#[macro_export]
28macro_rules! instrument_debug_span {
29 (
30 $fut:expr,
31 $($arg:tt)*
32 ) => {
33 {
34 #[cfg(feature = "tracing")]
35 {
36 use tracing::Instrument;
37 let span = tracing::debug_span!($($arg)+);
38 $fut.instrument(span)
39 }
40 #[cfg(not(feature = "tracing"))]
41 {
42 $fut
43 }
44 }
45 };
46}
47
48#[allow(unused_macros)]
49#[macro_export]
50macro_rules! error {
51 ($($arg:tt)*) => {
52 #[cfg(feature = "tracing")]
53 {
54 tracing::error!($($arg)+);
55 }
56 }
57}
58
59#[allow(unused_macros)]
60#[macro_export]
61macro_rules! error_span {
62 ($($arg:tt)*) => {
63 {
64 #[cfg(feature = "tracing")]
65 {
66 let _span = tracing::error_span!($($arg)+);
67 _span.entered()
68 }
69 }
70 }
71}
72
73#[allow(unused_macros)]
74#[macro_export]
75macro_rules! instrument_error_span {
76 (
77 $fut:expr,
78 $($arg:tt)*
79 ) => {
80 {
81 #[cfg(feature = "tracing")]
82 {
83 use tracing::Instrument;
84 let span = tracing::error_span!($($arg)+);
85 $fut.instrument(span)
86 }
87 #[cfg(not(feature = "tracing"))]
88 {
89 $fut
90 }
91 }
92 };
93}
94
95#[allow(unused_macros)]
96#[macro_export]
97macro_rules! info {
98 ($($arg:tt)*) => {
99 #[cfg(feature = "tracing")]
100 {
101 tracing::info!($($arg)+);
102 }
103 }
104}
105
106#[allow(unused_macros)]
107#[macro_export]
108macro_rules! info_span {
109 ($($arg:tt)*) => {
110 {
111 #[cfg(feature = "tracing")]
112 {
113 let _span = tracing::info_span!($($arg)+);
114 _span.entered()
115 }
116 }
117 }
118}
119
120#[allow(unused_macros)]
121#[macro_export]
122macro_rules! instrument_info_span {
123 (
124 $fut:expr,
125 $($arg:tt)*
126 ) => {
127 {
128 #[cfg(feature = "tracing")]
129 {
130 use tracing::Instrument;
131 let span = tracing::info_span!($($arg)+);
132 $fut.instrument(span)
133 }
134 #[cfg(not(feature = "tracing"))]
135 {
136 $fut
137 }
138 }
139 };
140}
141
142#[allow(unused_macros)]
143#[macro_export]
144macro_rules! trace {
145 ($($arg:tt)*) => {
146 #[cfg(feature = "tracing")]
147 {
148 tracing::trace!($($arg)+);
149 }
150 }
151}
152
153#[allow(unused_macros)]
154#[macro_export]
155macro_rules! trace_span {
156 ($($arg:tt)*) => {
157 {
158 #[cfg(feature = "tracing")]
159 {
160 let _span = tracing::trace_span!($($arg)+);
161 _span.entered()
162 }
163 }
164 }
165}
166
167#[allow(unused_macros)]
168#[macro_export]
169macro_rules! instrument_trace_span {
170 (
171 $fut:expr,
172 $($arg:tt)*
173 ) => {
174 {
175 #[cfg(feature = "tracing")]
176 {
177 use tracing::Instrument;
178 let span = tracing::trace_span!($($arg)+);
179 $fut.instrument(span)
180 }
181 #[cfg(not(feature = "tracing"))]
182 {
183 $fut
184 }
185 }
186 };
187}
188
189#[allow(unused_macros)]
190#[macro_export]
191macro_rules! span {
192 ($($arg:tt)*) => {
193 {
194 #[cfg(feature = "tracing")]
195 {
196 tracing::span!($($arg)+)
197 }
198 }
199 }
200}
201
202#[allow(unused_macros)]
203#[macro_export]
204macro_rules! warn2 {
205 ($($arg:tt)*) => {
206 #[cfg(feature = "tracing")]
207 {
208 tracing::warn!($($arg)+);
209 }
210 }
211}
212
213#[allow(unused_macros)]
214#[macro_export]
215macro_rules! warn_span {
216 ($($arg:tt)*) => {
217 {
218 #[cfg(feature = "tracing")]
219 {
220 let _span = tracing::warn_span!($($arg)+);
221 _span.entered()
222 }
223 }
224 }
225}
226
227#[allow(unused_macros)]
228#[macro_export]
229macro_rules! instrument_warn_span {
230 (
231 $fut:expr,
232 $($arg:tt)*
233 ) => {
234 {
235 #[cfg(feature = "tracing")]
236 {
237 use tracing::Instrument;
238 let span = tracing::warn_span!($($arg)+);
239 $fut.instrument(span)
240 }
241 #[cfg(not(feature = "tracing"))]
242 {
243 $fut
244 }
245 }
246 };
247}
248
249#[allow(unused_macros)]
251#[macro_export]
252macro_rules! instrument_current_span {
253 (
254 $fut:expr
255 ) => {{
256 #[cfg(feature = "tracing")]
257 {
258 use tracing::Instrument;
259 let span = tracing::Span::current();
260 $fut.instrument(span)
261 }
262 #[cfg(not(feature = "tracing"))]
263 {
264 $fut
265 }
266 }};
267}
268
269#[allow(unused_macros)]
270#[macro_export]
271macro_rules! tokio_spawn {
272 ($fut:expr) => {
273 tokio::spawn($fut)
274 };
275}
276
277#[allow(unused_imports)]
278pub use tokio_spawn;
279
280#[allow(unused_imports)]
281pub use debug;
282
283#[allow(unused_imports)]
284pub use debug_span;
285
286#[allow(unused_imports)]
287pub use instrument_debug_span;
288
289#[allow(unused_imports)]
290pub use error;
291
292#[allow(unused_imports)]
293pub use error_span;
294
295#[allow(unused_imports)]
296pub use instrument_error_span;
297
298#[allow(unused_imports)]
299pub use info;
300
301#[allow(unused_imports)]
302pub use info_span;
303
304#[allow(unused_imports)]
305pub use instrument_info_span;
306
307#[allow(unused_imports)]
308pub use trace;
309
310#[allow(unused_imports)]
311pub use trace_span;
312
313#[allow(unused_imports)]
314pub use instrument_trace_span;
315
316#[allow(unused_imports)]
317pub use span;
318
319#[allow(unused_imports)]
320pub use warn2; #[allow(unused_imports)]
323pub use warn_span;
324
325#[allow(unused_imports)]
326pub use instrument_warn_span;
327
328#[allow(unused_imports)]
329pub use instrument_current_span;