1 | #![deny (warnings)] |
2 | // We call all macros in this module with `no_implicit_prelude` to ensure they do not depend on the standard prelude. |
3 | #![no_implicit_prelude ] |
4 | extern crate tracing; |
5 | #[cfg (target_arch = "wasm32" )] |
6 | extern crate wasm_bindgen_test; |
7 | |
8 | // TODO: remove this once https://github.com/tokio-rs/tracing/pull/2675#issuecomment-1667628907 is resolved |
9 | #[cfg (target_arch = "wasm32" )] |
10 | use ::core::option::Option::None; |
11 | |
12 | use tracing::{ |
13 | callsite, debug, debug_span, enabled, error, error_span, event, event_enabled, info, info_span, |
14 | span, span_enabled, trace, trace_span, warn, warn_span, Level, |
15 | }; |
16 | |
17 | // Tests that macros work across various invocation syntax. |
18 | // |
19 | // These are quite repetitive, and _could_ be generated by a macro. However, |
20 | // they're compile-time tests, so I want to get line numbers etc out of |
21 | // failures, and producing them with a macro would muddy the waters a bit. |
22 | |
23 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
24 | #[test] |
25 | fn span() { |
26 | span!(target: "foo_events" , Level::DEBUG, "foo" , bar.baz = ?2, quux = %3, quuux = 4); |
27 | span!(target: "foo_events" , Level::DEBUG, "foo" , bar.baz = 2, quux = 3); |
28 | span!(target: "foo_events" , Level::DEBUG, "foo" , bar.baz = 2, quux = 4,); |
29 | span!(target: "foo_events" , Level::DEBUG, "foo" ); |
30 | span!(target: "foo_events" , Level::DEBUG, "bar" ,); |
31 | span!(Level::DEBUG, "foo" , bar.baz = 2, quux = 3); |
32 | span!(Level::DEBUG, "foo" , bar.baz = 2, quux = 4,); |
33 | span!(Level::DEBUG, "foo" , bar.baz = 2, quux = 3); |
34 | span!(Level::DEBUG, "foo" , bar.baz = 2, quux = 4,); |
35 | span!(Level::DEBUG, "foo" , bar.baz = ?2); |
36 | span!(Level::DEBUG, "foo" , bar.baz = %2); |
37 | span!(Level::DEBUG, "foo" ); |
38 | span!(Level::DEBUG, "bar" ,); |
39 | } |
40 | |
41 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
42 | #[test] |
43 | fn trace_span() { |
44 | trace_span!(target: "foo_events" , "foo" , bar.baz = ?2, quux = %3, quuux = 4); |
45 | trace_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 3); |
46 | trace_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 4,); |
47 | trace_span!(target: "foo_events" , "foo" ); |
48 | trace_span!(target: "foo_events" , "bar" ,); |
49 | trace_span!("foo" , bar.baz = 2, quux = 3); |
50 | trace_span!("foo" , bar.baz = 2, quux = 4,); |
51 | trace_span!("foo" , bar.baz = ?2); |
52 | trace_span!("foo" , bar.baz = %2); |
53 | trace_span!("bar" ); |
54 | trace_span!("bar" ,); |
55 | } |
56 | |
57 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
58 | #[test] |
59 | fn debug_span() { |
60 | debug_span!(target: "foo_events" , "foo" , bar.baz = ?2, quux = %3, quuux = 4); |
61 | debug_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 3); |
62 | debug_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 4,); |
63 | debug_span!(target: "foo_events" , "foo" ); |
64 | debug_span!(target: "foo_events" , "bar" ,); |
65 | debug_span!("foo" , bar.baz = 2, quux = 3); |
66 | debug_span!("foo" , bar.baz = 2, quux = 4,); |
67 | debug_span!("foo" , bar.baz = ?2); |
68 | debug_span!("foo" , bar.baz = %2); |
69 | debug_span!("bar" ); |
70 | debug_span!("bar" ,); |
71 | } |
72 | |
73 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
74 | #[test] |
75 | fn info_span() { |
76 | info_span!(target: "foo_events" , "foo" , bar.baz = ?2, quux = %3, quuux = 4); |
77 | info_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 3); |
78 | info_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 4,); |
79 | info_span!(target: "foo_events" , "foo" ); |
80 | info_span!(target: "foo_events" , "bar" ,); |
81 | info_span!("foo" , bar.baz = 2, quux = 3); |
82 | info_span!("foo" , bar.baz = 2, quux = 4,); |
83 | info_span!("foo" , bar.baz = ?2); |
84 | info_span!("foo" , bar.baz = %2); |
85 | info_span!("bar" ); |
86 | info_span!("bar" ,); |
87 | } |
88 | |
89 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
90 | #[test] |
91 | fn warn_span() { |
92 | warn_span!(target: "foo_events" , "foo" , bar.baz = ?2, quux = %3, quuux = 4); |
93 | warn_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 3); |
94 | warn_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 4,); |
95 | warn_span!(target: "foo_events" , "foo" ); |
96 | warn_span!(target: "foo_events" , "bar" ,); |
97 | warn_span!("foo" , bar.baz = 2, quux = 3); |
98 | warn_span!("foo" , bar.baz = 2, quux = 4,); |
99 | warn_span!("foo" , bar.baz = ?2); |
100 | warn_span!("foo" , bar.baz = %2); |
101 | warn_span!("bar" ); |
102 | warn_span!("bar" ,); |
103 | } |
104 | |
105 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
106 | #[test] |
107 | fn error_span() { |
108 | error_span!(target: "foo_events" , "foo" , bar.baz = ?2, quux = %3, quuux = 4); |
109 | error_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 3); |
110 | error_span!(target: "foo_events" , "foo" , bar.baz = 2, quux = 4,); |
111 | error_span!(target: "foo_events" , "foo" ); |
112 | error_span!(target: "foo_events" , "bar" ,); |
113 | error_span!("foo" , bar.baz = 2, quux = 3); |
114 | error_span!("foo" , bar.baz = 2, quux = 4,); |
115 | error_span!("foo" , bar.baz = ?2); |
116 | error_span!("foo" , bar.baz = %2); |
117 | error_span!("bar" ); |
118 | error_span!("bar" ,); |
119 | } |
120 | |
121 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
122 | #[test] |
123 | fn span_root() { |
124 | span!(target: "foo_events" , parent: ::core::option::Option::None, Level::TRACE, "foo" , bar.baz = 2, quux = 3); |
125 | span!(target: "foo_events" , parent: ::core::option::Option::None, Level::TRACE, "foo" , bar.baz = 2, quux = 3); |
126 | span!(target: "foo_events" , parent: ::core::option::Option::None, Level::TRACE, "foo" , bar.baz = 2, quux = 4,); |
127 | span!(target: "foo_events" , parent: ::core::option::Option::None, Level::TRACE, "foo" ); |
128 | span!(target: "foo_events" , parent: ::core::option::Option::None, Level::TRACE, "bar" ,); |
129 | span!( |
130 | parent: ::core::option::Option::None, |
131 | Level::DEBUG, |
132 | "foo" , |
133 | bar.baz = 2, |
134 | quux = 3 |
135 | ); |
136 | span!( |
137 | parent: ::core::option::Option::None, |
138 | Level::DEBUG, |
139 | "foo" , |
140 | bar.baz = 2, |
141 | quux = 4, |
142 | ); |
143 | span!(parent: ::core::option::Option::None, Level::DEBUG, "foo" ); |
144 | span!(parent: ::core::option::Option::None, Level::DEBUG, "bar" ,); |
145 | } |
146 | |
147 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
148 | #[test] |
149 | fn trace_span_root() { |
150 | trace_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 3); |
151 | trace_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 4,); |
152 | trace_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
153 | trace_span!(target: "foo_events" , parent: ::core::option::Option::None, "bar" ,); |
154 | trace_span!( |
155 | parent: ::core::option::Option::None, |
156 | "foo" , |
157 | bar.baz = 2, |
158 | quux = 3 |
159 | ); |
160 | trace_span!( |
161 | parent: ::core::option::Option::None, |
162 | "foo" , |
163 | bar.baz = 2, |
164 | quux = 4, |
165 | ); |
166 | trace_span!(parent: ::core::option::Option::None, "foo" ); |
167 | trace_span!(parent: ::core::option::Option::None, "bar" ,); |
168 | } |
169 | |
170 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
171 | #[test] |
172 | fn debug_span_root() { |
173 | debug_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 3); |
174 | debug_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 4,); |
175 | debug_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
176 | debug_span!(target: "foo_events" , parent: ::core::option::Option::None, "bar" ,); |
177 | debug_span!( |
178 | parent: ::core::option::Option::None, |
179 | "foo" , |
180 | bar.baz = 2, |
181 | quux = 3 |
182 | ); |
183 | debug_span!( |
184 | parent: ::core::option::Option::None, |
185 | "foo" , |
186 | bar.baz = 2, |
187 | quux = 4, |
188 | ); |
189 | debug_span!(parent: ::core::option::Option::None, "foo" ); |
190 | debug_span!(parent: ::core::option::Option::None, "bar" ,); |
191 | } |
192 | |
193 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
194 | #[test] |
195 | fn info_span_root() { |
196 | info_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 3); |
197 | info_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 4,); |
198 | info_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
199 | info_span!(target: "foo_events" , parent: ::core::option::Option::None, "bar" ,); |
200 | info_span!( |
201 | parent: ::core::option::Option::None, |
202 | "foo" , |
203 | bar.baz = 2, |
204 | quux = 3 |
205 | ); |
206 | info_span!( |
207 | parent: ::core::option::Option::None, |
208 | "foo" , |
209 | bar.baz = 2, |
210 | quux = 4, |
211 | ); |
212 | info_span!(parent: ::core::option::Option::None, "foo" ); |
213 | info_span!(parent: ::core::option::Option::None, "bar" ,); |
214 | } |
215 | |
216 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
217 | #[test] |
218 | fn warn_span_root() { |
219 | warn_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 3); |
220 | warn_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 4,); |
221 | warn_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
222 | warn_span!(target: "foo_events" , parent: ::core::option::Option::None, "bar" ,); |
223 | warn_span!( |
224 | parent: ::core::option::Option::None, |
225 | "foo" , |
226 | bar.baz = 2, |
227 | quux = 3 |
228 | ); |
229 | warn_span!( |
230 | parent: ::core::option::Option::None, |
231 | "foo" , |
232 | bar.baz = 2, |
233 | quux = 4, |
234 | ); |
235 | warn_span!(parent: ::core::option::Option::None, "foo" ); |
236 | warn_span!(parent: ::core::option::Option::None, "bar" ,); |
237 | } |
238 | |
239 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
240 | #[test] |
241 | fn error_span_root() { |
242 | error_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 3); |
243 | error_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" , bar.baz = 2, quux = 4,); |
244 | error_span!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
245 | error_span!(target: "foo_events" , parent: ::core::option::Option::None, "bar" ,); |
246 | error_span!( |
247 | parent: ::core::option::Option::None, |
248 | "foo" , |
249 | bar.baz = 2, |
250 | quux = 3 |
251 | ); |
252 | error_span!( |
253 | parent: ::core::option::Option::None, |
254 | "foo" , |
255 | bar.baz = 2, |
256 | quux = 4, |
257 | ); |
258 | error_span!(parent: ::core::option::Option::None, "foo" ); |
259 | error_span!(parent: ::core::option::Option::None, "bar" ,); |
260 | } |
261 | |
262 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
263 | #[test] |
264 | fn span_with_parent() { |
265 | let p = span!(Level::TRACE, "im_a_parent!" ); |
266 | span!(target: "foo_events" , parent: &p, Level::TRACE, "foo" , bar.baz = 2, quux = 3); |
267 | span!(target: "foo_events" , parent: &p, Level::TRACE, "foo" , bar.baz = 2, quux = 4,); |
268 | span!(target: "foo_events" , parent: &p, Level::TRACE, "foo" ); |
269 | span!(target: "foo_events" , parent: &p, Level::TRACE, "bar" ,); |
270 | span!(parent: &p, Level::DEBUG, "foo" , bar.baz = 2, quux = 3); |
271 | span!(parent: &p, Level::DEBUG, "foo" , bar.baz = 2, quux = 4,); |
272 | span!(parent: &p, Level::DEBUG, "foo" ); |
273 | span!(parent: &p, Level::DEBUG, "bar" ,); |
274 | } |
275 | |
276 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
277 | #[test] |
278 | fn trace_span_with_parent() { |
279 | let p = span!(Level::TRACE, "im_a_parent!" ); |
280 | trace_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 3); |
281 | trace_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 4,); |
282 | trace_span!(target: "foo_events" , parent: &p, "foo" ); |
283 | trace_span!(target: "foo_events" , parent: &p, "bar" ,); |
284 | |
285 | trace_span!(parent: &p, "foo" , bar.baz = 2, quux = 3); |
286 | trace_span!(parent: &p, "foo" , bar.baz = 2, quux = 4,); |
287 | |
288 | trace_span!(parent: &p, "foo" ); |
289 | trace_span!(parent: &p, "bar" ,); |
290 | } |
291 | |
292 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
293 | #[test] |
294 | fn debug_span_with_parent() { |
295 | let p = span!(Level::TRACE, "im_a_parent!" ); |
296 | debug_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 3); |
297 | debug_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 4,); |
298 | debug_span!(target: "foo_events" , parent: &p, "foo" ); |
299 | debug_span!(target: "foo_events" , parent: &p, "bar" ,); |
300 | |
301 | debug_span!(parent: &p, "foo" , bar.baz = 2, quux = 3); |
302 | debug_span!(parent: &p, "foo" , bar.baz = 2, quux = 4,); |
303 | |
304 | debug_span!(parent: &p, "foo" ); |
305 | debug_span!(parent: &p, "bar" ,); |
306 | } |
307 | |
308 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
309 | #[test] |
310 | fn info_span_with_parent() { |
311 | let p = span!(Level::TRACE, "im_a_parent!" ); |
312 | info_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 3); |
313 | info_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 4,); |
314 | info_span!(target: "foo_events" , parent: &p, "foo" ); |
315 | info_span!(target: "foo_events" , parent: &p, "bar" ,); |
316 | |
317 | info_span!(parent: &p, "foo" , bar.baz = 2, quux = 3); |
318 | info_span!(parent: &p, "foo" , bar.baz = 2, quux = 4,); |
319 | |
320 | info_span!(parent: &p, "foo" ); |
321 | info_span!(parent: &p, "bar" ,); |
322 | } |
323 | |
324 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
325 | #[test] |
326 | fn warn_span_with_parent() { |
327 | let p = span!(Level::TRACE, "im_a_parent!" ); |
328 | warn_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 3); |
329 | warn_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 4,); |
330 | warn_span!(target: "foo_events" , parent: &p, "foo" ); |
331 | warn_span!(target: "foo_events" , parent: &p, "bar" ,); |
332 | |
333 | warn_span!(parent: &p, "foo" , bar.baz = 2, quux = 3); |
334 | warn_span!(parent: &p, "foo" , bar.baz = 2, quux = 4,); |
335 | |
336 | warn_span!(parent: &p, "foo" ); |
337 | warn_span!(parent: &p, "bar" ,); |
338 | } |
339 | |
340 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
341 | #[test] |
342 | fn error_span_with_parent() { |
343 | let p = span!(Level::TRACE, "im_a_parent!" ); |
344 | error_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 3); |
345 | error_span!(target: "foo_events" , parent: &p, "foo" , bar.baz = 2, quux = 4,); |
346 | error_span!(target: "foo_events" , parent: &p, "foo" ); |
347 | error_span!(target: "foo_events" , parent: &p, "bar" ,); |
348 | |
349 | error_span!(parent: &p, "foo" , bar.baz = 2, quux = 3); |
350 | error_span!(parent: &p, "foo" , bar.baz = 2, quux = 4,); |
351 | |
352 | error_span!(parent: &p, "foo" ); |
353 | error_span!(parent: &p, "bar" ,); |
354 | } |
355 | |
356 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
357 | #[test] |
358 | fn span_with_non_rust_symbol() { |
359 | span!(Level::TRACE, "non-rust" , "guid:x-request-id" = ?"abcdef" , "more {}" , 42); |
360 | span!(Level::TRACE, "non-rust" , "guid:x-request-id" = %"abcdef" , "more {}" , 51); |
361 | span!( |
362 | Level::TRACE, |
363 | "non-rust" , |
364 | "guid:x-request-id" = "abcdef" , |
365 | "more {}" , |
366 | 60 |
367 | ); |
368 | span!(Level::TRACE, "non-rust" , "guid:x-request-id" = ?"abcdef" ); |
369 | span!(Level::TRACE, "non-rust" , "guid:x-request-id" = %"abcdef" ); |
370 | span!(Level::TRACE, "non-rust" , "guid:x-request-id" = "abcdef" ); |
371 | } |
372 | |
373 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
374 | #[test] |
375 | fn large_span() { |
376 | span!( |
377 | Level::TRACE, |
378 | "spans with more than 32 fields have been supported since #2508" , |
379 | a = 1, |
380 | b = 2, |
381 | c = 3, |
382 | d = 4, |
383 | e = 5, |
384 | f = 6, |
385 | g = 7, |
386 | h = 8, |
387 | i = 9, |
388 | j = 10, |
389 | k = 11, |
390 | l = 12, |
391 | m = 13, |
392 | n = 14, |
393 | o = 15, |
394 | p = 16, |
395 | q = 17, |
396 | r = 18, |
397 | s = 19, |
398 | t = 20, |
399 | u = 21, |
400 | v = 22, |
401 | w = 23, |
402 | x = 24, |
403 | y = 25, |
404 | z = 26, |
405 | aa = 27, |
406 | bb = 28, |
407 | cc = 29, |
408 | dd = 30, |
409 | ee = 31, |
410 | ff = 32, |
411 | gg = 33 |
412 | ); |
413 | } |
414 | |
415 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
416 | #[test] |
417 | fn event() { |
418 | event!(Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); |
419 | event!(Level::DEBUG, foo = 3, bar.baz = 2, quux = false); |
420 | event!(Level::DEBUG, foo = 3, bar.baz = 3,); |
421 | event!(Level::DEBUG, "foo" ); |
422 | event!(Level::DEBUG, "foo: {}" , 3); |
423 | event!(Level::INFO, foo = ?3, bar.baz = %2, quux = false, "hello world {:?}" , 42); |
424 | event!( |
425 | Level::INFO, |
426 | foo = 3, |
427 | bar.baz = 2, |
428 | quux = false, |
429 | "hello world {:?}" , |
430 | 42 |
431 | ); |
432 | event!(Level::INFO, foo = 3, bar.baz = 3, "hello world {:?}" , 42,); |
433 | event!(Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
434 | event!(Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
435 | event!(Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
436 | event!(Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux" ); |
437 | event!(target: "foo_events" , Level::DEBUG, foo = 3, bar.baz = 2, quux = false); |
438 | event!(target: "foo_events" , Level::DEBUG, foo = 3, bar.baz = 3,); |
439 | event!(target: "foo_events" , Level::DEBUG, "foo" ); |
440 | event!(target: "foo_events" , Level::DEBUG, "foo: {}" , 3); |
441 | event!(target: "foo_events" , Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
442 | event!(target: "foo_events" , Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
443 | event!(target: "foo_events" , Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
444 | event!(target: "foo_events" , Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux" ); |
445 | let foo = 1; |
446 | event!(Level::DEBUG, ?foo); |
447 | event!(Level::DEBUG, %foo); |
448 | event!(Level::DEBUG, foo); |
449 | } |
450 | |
451 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
452 | #[test] |
453 | fn enabled() { |
454 | enabled!(Level::DEBUG, foo, bar.baz, quux,); |
455 | enabled!(Level::DEBUG, message); |
456 | enabled!(Level::INFO, foo, bar.baz, quux, message,); |
457 | enabled!(Level::INFO, foo, bar., message,); |
458 | enabled!(Level::DEBUG, foo); |
459 | |
460 | enabled!(Level::DEBUG); |
461 | enabled!(target: "rando" , Level::DEBUG); |
462 | enabled!(target: "rando" , Level::DEBUG, field); |
463 | } |
464 | |
465 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
466 | #[test] |
467 | fn span_enabled() { |
468 | span_enabled!(Level::DEBUG, foo, bar.baz, quux,); |
469 | span_enabled!(Level::DEBUG, message); |
470 | span_enabled!(Level::INFO, foo, bar.baz, quux, message,); |
471 | span_enabled!(Level::INFO, foo, bar., message,); |
472 | span_enabled!(Level::DEBUG, foo); |
473 | |
474 | span_enabled!(Level::DEBUG); |
475 | span_enabled!(target: "rando" , Level::DEBUG); |
476 | span_enabled!(target: "rando" , Level::DEBUG, field); |
477 | } |
478 | |
479 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
480 | #[test] |
481 | fn event_enabled() { |
482 | event_enabled!(Level::DEBUG, foo, bar.baz, quux,); |
483 | event_enabled!(Level::DEBUG, message); |
484 | event_enabled!(Level::INFO, foo, bar.baz, quux, message,); |
485 | event_enabled!(Level::INFO, foo, bar., message,); |
486 | event_enabled!(Level::DEBUG, foo); |
487 | |
488 | event_enabled!(Level::DEBUG); |
489 | event_enabled!(target: "rando" , Level::DEBUG); |
490 | event_enabled!(target: "rando" , Level::DEBUG, field); |
491 | } |
492 | |
493 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
494 | #[test] |
495 | fn locals_with_message() { |
496 | let data = (42, "forty-two" ); |
497 | let private_data = "private" ; |
498 | let error = "a bad error" ; |
499 | event!(Level::ERROR, %error, "Received error" ); |
500 | event!( |
501 | target: "app_events" , |
502 | Level::WARN, |
503 | private_data, |
504 | ?data, |
505 | "App warning: {}" , |
506 | error |
507 | ); |
508 | } |
509 | |
510 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
511 | #[test] |
512 | fn locals_no_message() { |
513 | let data = (42, "forty-two" ); |
514 | let private_data = "private" ; |
515 | let error = "a bad error" ; |
516 | event!( |
517 | name: "foo" , |
518 | target: "app_events" , |
519 | Level::WARN, |
520 | private_data, |
521 | ?data, |
522 | ); |
523 | event!( |
524 | target: "app_events" , |
525 | Level::WARN, |
526 | private_data, |
527 | ?data, |
528 | ); |
529 | event!( |
530 | target: "app_events" , |
531 | Level::WARN, |
532 | private_data, |
533 | ?data, |
534 | error, |
535 | ); |
536 | event!( |
537 | target: "app_events" , |
538 | Level::WARN, |
539 | private_data, |
540 | ?data, |
541 | error |
542 | ); |
543 | event!(Level::WARN, private_data, ?data, error,); |
544 | } |
545 | |
546 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
547 | #[test] |
548 | fn trace() { |
549 | trace!(foo = ?3, bar.baz = %2, quux = false); |
550 | trace!(foo = 3, bar.baz = 2, quux = false); |
551 | trace!(foo = 3, bar.baz = 3,); |
552 | trace!("foo" ); |
553 | trace!("foo: {}" , 3); |
554 | trace!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}" , 42); |
555 | trace!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}" , 42); |
556 | trace!(foo = 3, bar.baz = 3, "hello world {:?}" , 42,); |
557 | trace!({ foo = 3, bar.baz = 80 }, "quux" ); |
558 | trace!({ foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
559 | trace!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
560 | trace!({ foo = 2, bar.baz = 78 }, "quux" ); |
561 | trace!({ foo = ?2, bar.baz = %78 }, "quux" ); |
562 | trace!(name: "foo" , foo = 3, bar.baz = 2, quux = false); |
563 | trace!(name: "foo" , target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
564 | trace!(target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
565 | trace!(target: "foo_events" , foo = 3, bar.baz = 3,); |
566 | trace!(target: "foo_events" , "foo" ); |
567 | trace!(target: "foo_events" , "foo: {}" , 3); |
568 | trace!(target: "foo_events" , { foo = 3, bar.baz = 80 }, "quux" ); |
569 | trace!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
570 | trace!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
571 | trace!(target: "foo_events" , { foo = 2, bar.baz = 78, }, "quux" ); |
572 | let foo = 1; |
573 | trace!(?foo); |
574 | trace!(%foo); |
575 | trace!(foo); |
576 | trace!(name: "foo" , ?foo); |
577 | trace!(name: "foo" , %foo); |
578 | trace!(name: "foo" , foo); |
579 | trace!(name: "foo" , ?foo, true, "message" ); |
580 | trace!(name: "foo" , %foo, true, "message" ); |
581 | trace!(name: "foo" , foo, true, "message" ); |
582 | trace!(target: "foo_events" , ?foo); |
583 | trace!(target: "foo_events" , %foo); |
584 | trace!(target: "foo_events" , foo); |
585 | trace!(target: "foo_events" , ?foo, true, "message" ); |
586 | trace!(target: "foo_events" , %foo, true, "message" ); |
587 | trace!(target: "foo_events" , foo, true, "message" ); |
588 | } |
589 | |
590 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
591 | #[test] |
592 | fn debug() { |
593 | debug!(foo = ?3, bar.baz = %2, quux = false); |
594 | debug!(foo = 3, bar.baz = 2, quux = false); |
595 | debug!(foo = 3, bar.baz = 3,); |
596 | debug!("foo" ); |
597 | debug!("foo: {}" , 3); |
598 | debug!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}" , 42); |
599 | debug!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}" , 42); |
600 | debug!(foo = 3, bar.baz = 3, "hello world {:?}" , 42,); |
601 | debug!({ foo = 3, bar.baz = 80 }, "quux" ); |
602 | debug!({ foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
603 | debug!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
604 | debug!({ foo = 2, bar.baz = 78 }, "quux" ); |
605 | debug!({ foo = ?2, bar.baz = %78 }, "quux" ); |
606 | debug!(name: "foo" , foo = 3, bar.baz = 2, quux = false); |
607 | debug!(name: "foo" , target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
608 | debug!(target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
609 | debug!(target: "foo_events" , foo = 3, bar.baz = 3,); |
610 | debug!(target: "foo_events" , "foo" ); |
611 | debug!(target: "foo_events" , "foo: {}" , 3); |
612 | debug!(target: "foo_events" , { foo = 3, bar.baz = 80 }, "quux" ); |
613 | debug!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
614 | debug!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
615 | debug!(target: "foo_events" , { foo = 2, bar.baz = 78, }, "quux" ); |
616 | let foo = 1; |
617 | debug!(?foo); |
618 | debug!(%foo); |
619 | debug!(foo); |
620 | debug!(name: "foo" , ?foo); |
621 | debug!(name: "foo" , %foo); |
622 | debug!(name: "foo" , foo); |
623 | debug!(name: "foo" , ?foo, true, "message" ); |
624 | debug!(name: "foo" , %foo, true, "message" ); |
625 | debug!(name: "foo" , foo, true, "message" ); |
626 | debug!(target: "foo_events" , ?foo); |
627 | debug!(target: "foo_events" , %foo); |
628 | debug!(target: "foo_events" , foo); |
629 | debug!(target: "foo_events" , ?foo, true, "message" ); |
630 | debug!(target: "foo_events" , %foo, true, "message" ); |
631 | debug!(target: "foo_events" , foo, true, "message" ); |
632 | } |
633 | |
634 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
635 | #[test] |
636 | fn info() { |
637 | info!(foo = ?3, bar.baz = %2, quux = false); |
638 | info!(foo = 3, bar.baz = 2, quux = false); |
639 | info!(foo = 3, bar.baz = 3,); |
640 | info!("foo" ); |
641 | info!("foo: {}" , 3); |
642 | info!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}" , 42); |
643 | info!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}" , 42); |
644 | info!(foo = 3, bar.baz = 3, "hello world {:?}" , 42,); |
645 | info!({ foo = 3, bar.baz = 80 }, "quux" ); |
646 | info!({ foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
647 | info!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
648 | info!({ foo = 2, bar.baz = 78 }, "quux" ); |
649 | info!({ foo = ?2, bar.baz = %78 }, "quux" ); |
650 | info!(name: "foo" , foo = 3, bar.baz = 2, quux = false); |
651 | info!(name: "foo" , target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
652 | info!(target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
653 | info!(target: "foo_events" , foo = 3, bar.baz = 3,); |
654 | info!(target: "foo_events" , "foo" ); |
655 | info!(target: "foo_events" , "foo: {}" , 3); |
656 | info!(target: "foo_events" , { foo = 3, bar.baz = 80 }, "quux" ); |
657 | info!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
658 | info!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
659 | info!(target: "foo_events" , { foo = 2, bar.baz = 78, }, "quux" ); |
660 | let foo = 1; |
661 | info!(?foo); |
662 | info!(%foo); |
663 | info!(foo); |
664 | info!(name: "foo" , ?foo); |
665 | info!(name: "foo" , %foo); |
666 | info!(name: "foo" , foo); |
667 | info!(name: "foo" , ?foo, true, "message" ); |
668 | info!(name: "foo" , %foo, true, "message" ); |
669 | info!(name: "foo" , foo, true, "message" ); |
670 | info!(target: "foo_events" , ?foo); |
671 | info!(target: "foo_events" , %foo); |
672 | info!(target: "foo_events" , foo); |
673 | info!(target: "foo_events" , ?foo, true, "message" ); |
674 | info!(target: "foo_events" , %foo, true, "message" ); |
675 | info!(target: "foo_events" , foo, true, "message" ); |
676 | } |
677 | |
678 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
679 | #[test] |
680 | fn warn() { |
681 | warn!(foo = ?3, bar.baz = %2, quux = false); |
682 | warn!(foo = 3, bar.baz = 2, quux = false); |
683 | warn!(foo = 3, bar.baz = 3,); |
684 | warn!("foo" ); |
685 | warn!("foo: {}" , 3); |
686 | warn!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}" , 42); |
687 | warn!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}" , 42); |
688 | warn!(foo = 3, bar.baz = 3, "hello world {:?}" , 42,); |
689 | warn!({ foo = 3, bar.baz = 80 }, "quux" ); |
690 | warn!({ foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
691 | warn!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
692 | warn!({ foo = 2, bar.baz = 78 }, "quux" ); |
693 | warn!({ foo = ?2, bar.baz = %78 }, "quux" ); |
694 | warn!(name: "foo" , foo = 3, bar.baz = 2, quux = false); |
695 | warn!(name: "foo" , target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
696 | warn!(target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
697 | warn!(target: "foo_events" , foo = 3, bar.baz = 3,); |
698 | warn!(target: "foo_events" , "foo" ); |
699 | warn!(target: "foo_events" , "foo: {}" , 3); |
700 | warn!(target: "foo_events" , { foo = 3, bar.baz = 80 }, "quux" ); |
701 | warn!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
702 | warn!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
703 | warn!(target: "foo_events" , { foo = 2, bar.baz = 78, }, "quux" ); |
704 | let foo = 1; |
705 | warn!(?foo); |
706 | warn!(%foo); |
707 | warn!(foo); |
708 | warn!(name: "foo" , ?foo); |
709 | warn!(name: "foo" , %foo); |
710 | warn!(name: "foo" , foo); |
711 | warn!(name: "foo" , ?foo, true, "message" ); |
712 | warn!(name: "foo" , %foo, true, "message" ); |
713 | warn!(name: "foo" , foo, true, "message" ); |
714 | warn!(target: "foo_events" , ?foo); |
715 | warn!(target: "foo_events" , %foo); |
716 | warn!(target: "foo_events" , foo); |
717 | warn!(target: "foo_events" , ?foo, true, "message" ); |
718 | warn!(target: "foo_events" , %foo, true, "message" ); |
719 | warn!(target: "foo_events" , foo, true, "message" ); |
720 | } |
721 | |
722 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
723 | #[test] |
724 | fn error() { |
725 | error!(foo = ?3, bar.baz = %2, quux = false); |
726 | error!(foo = 3, bar.baz = 2, quux = false); |
727 | error!(foo = 3, bar.baz = 3,); |
728 | error!("foo" ); |
729 | error!("foo: {}" , 3); |
730 | error!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}" , 42); |
731 | error!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}" , 42); |
732 | error!(foo = 3, bar.baz = 3, "hello world {:?}" , 42,); |
733 | error!({ foo = 3, bar.baz = 80 }, "quux" ); |
734 | error!({ foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
735 | error!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
736 | error!({ foo = 2, bar.baz = 78, }, "quux" ); |
737 | error!({ foo = ?2, bar.baz = %78 }, "quux" ); |
738 | error!(name: "foo" , foo = 3, bar.baz = 2, quux = false); |
739 | error!(name: "foo" , target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
740 | error!(target: "foo_events" , foo = 3, bar.baz = 2, quux = false); |
741 | error!(target: "foo_events" , foo = 3, bar.baz = 3,); |
742 | error!(target: "foo_events" , "foo" ); |
743 | error!(target: "foo_events" , "foo: {}" , 3); |
744 | error!(target: "foo_events" , { foo = 3, bar.baz = 80 }, "quux" ); |
745 | error!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
746 | error!(target: "foo_events" , { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
747 | error!(target: "foo_events" , { foo = 2, bar.baz = 78, }, "quux" ); |
748 | let foo = 1; |
749 | error!(?foo); |
750 | error!(%foo); |
751 | error!(foo); |
752 | error!(name: "foo" , ?foo); |
753 | error!(name: "foo" , %foo); |
754 | error!(name: "foo" , foo); |
755 | error!(name: "foo" , ?foo, true, "message" ); |
756 | error!(name: "foo" , %foo, true, "message" ); |
757 | error!(name: "foo" , foo, true, "message" ); |
758 | error!(target: "foo_events" , ?foo); |
759 | error!(target: "foo_events" , %foo); |
760 | error!(target: "foo_events" , foo); |
761 | error!(target: "foo_events" , ?foo, true, "message" ); |
762 | error!(target: "foo_events" , %foo, true, "message" ); |
763 | error!(target: "foo_events" , foo, true, "message" ); |
764 | } |
765 | |
766 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
767 | #[test] |
768 | fn event_root() { |
769 | event!(parent: ::core::option::Option::None, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); |
770 | event!( |
771 | parent: ::core::option::Option::None, |
772 | Level::DEBUG, |
773 | foo = 3, |
774 | bar.baz = 2, |
775 | quux = false |
776 | ); |
777 | event!( |
778 | parent: ::core::option::Option::None, |
779 | Level::DEBUG, |
780 | foo = 3, |
781 | bar.baz = 3, |
782 | ); |
783 | event!(parent: ::core::option::Option::None, Level::DEBUG, "foo" ); |
784 | event!( |
785 | parent: ::core::option::Option::None, |
786 | Level::DEBUG, |
787 | "foo: {}" , |
788 | 3 |
789 | ); |
790 | event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
791 | event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
792 | event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
793 | event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux" ); |
794 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); |
795 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 3,); |
796 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, "foo" ); |
797 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, "foo: {}" , 3); |
798 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
799 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
800 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
801 | event!(target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux" ); |
802 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); |
803 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 3,); |
804 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, "foo" ); |
805 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, "foo: {}" , 3); |
806 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
807 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
808 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
809 | event!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux" ); |
810 | } |
811 | |
812 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
813 | #[test] |
814 | fn trace_root() { |
815 | trace!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); |
816 | trace!( |
817 | parent: ::core::option::Option::None, |
818 | foo = 3, |
819 | bar.baz = 2, |
820 | quux = false |
821 | ); |
822 | trace!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
823 | trace!(parent: ::core::option::Option::None, "foo" ); |
824 | trace!(parent: ::core::option::Option::None, "foo: {}" , 3); |
825 | trace!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
826 | trace!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
827 | trace!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
828 | trace!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux" ); |
829 | trace!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux" ); |
830 | trace!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
831 | trace!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
832 | trace!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
833 | trace!(target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
834 | trace!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
835 | trace!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
836 | trace!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
837 | trace!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
838 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
839 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
840 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
841 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
842 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
843 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
844 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
845 | trace!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
846 | } |
847 | |
848 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
849 | #[test] |
850 | fn debug_root() { |
851 | debug!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); |
852 | debug!( |
853 | parent: ::core::option::Option::None, |
854 | foo = 3, |
855 | bar.baz = 2, |
856 | quux = false |
857 | ); |
858 | debug!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
859 | debug!(parent: ::core::option::Option::None, "foo" ); |
860 | debug!(parent: ::core::option::Option::None, "foo: {}" , 3); |
861 | debug!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
862 | debug!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
863 | debug!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
864 | debug!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux" ); |
865 | debug!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux" ); |
866 | debug!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
867 | debug!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
868 | debug!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
869 | debug!(target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
870 | debug!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
871 | debug!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
872 | debug!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
873 | debug!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
874 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
875 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
876 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
877 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
878 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
879 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
880 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
881 | debug!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
882 | } |
883 | |
884 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
885 | #[test] |
886 | fn info_root() { |
887 | info!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); |
888 | info!( |
889 | parent: ::core::option::Option::None, |
890 | foo = 3, |
891 | bar.baz = 2, |
892 | quux = false |
893 | ); |
894 | info!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
895 | info!(parent: ::core::option::Option::None, "foo" ); |
896 | info!(parent: ::core::option::Option::None, "foo: {}" , 3); |
897 | info!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
898 | info!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
899 | info!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
900 | info!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux" ); |
901 | info!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux" ); |
902 | info!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
903 | info!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
904 | info!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
905 | info!(target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
906 | info!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
907 | info!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
908 | info!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
909 | info!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
910 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
911 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
912 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
913 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
914 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
915 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
916 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
917 | info!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
918 | } |
919 | |
920 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
921 | #[test] |
922 | fn warn_root() { |
923 | warn!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); |
924 | warn!( |
925 | parent: ::core::option::Option::None, |
926 | foo = 3, |
927 | bar.baz = 2, |
928 | quux = false |
929 | ); |
930 | warn!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
931 | warn!(parent: ::core::option::Option::None, "foo" ); |
932 | warn!(parent: ::core::option::Option::None, "foo: {}" , 3); |
933 | warn!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
934 | warn!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
935 | warn!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
936 | warn!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux" ); |
937 | warn!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux" ); |
938 | warn!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
939 | warn!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
940 | warn!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
941 | warn!(target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
942 | warn!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
943 | warn!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
944 | warn!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
945 | warn!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
946 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
947 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
948 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
949 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
950 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
951 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
952 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
953 | warn!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
954 | } |
955 | |
956 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
957 | #[test] |
958 | fn error_root() { |
959 | error!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); |
960 | error!( |
961 | parent: ::core::option::Option::None, |
962 | foo = 3, |
963 | bar.baz = 2, |
964 | quux = false |
965 | ); |
966 | error!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
967 | error!(parent: ::core::option::Option::None, "foo" ); |
968 | error!(parent: ::core::option::Option::None, "foo: {}" , 3); |
969 | error!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
970 | error!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
971 | error!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
972 | error!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux" ); |
973 | error!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux" ); |
974 | error!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
975 | error!(target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
976 | error!(target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
977 | error!(target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
978 | error!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
979 | error!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
980 | error!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
981 | error!(target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
982 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); |
983 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); |
984 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo" ); |
985 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, "foo: {}" , 3); |
986 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux" ); |
987 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
988 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
989 | error!(name: "foo" , target: "foo_events" , parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux" ); |
990 | } |
991 | |
992 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
993 | #[test] |
994 | fn event_with_parent() { |
995 | let p = span!(Level::TRACE, "im_a_parent!" ); |
996 | event!(parent: &p, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); |
997 | event!(parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); |
998 | event!(parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,); |
999 | event!(parent: &p, Level::DEBUG, "foo" ); |
1000 | event!(parent: &p, Level::DEBUG, "foo: {}" , 3); |
1001 | event!(parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
1002 | event!(parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1003 | event!(parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1004 | event!(parent: &p, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux" ); |
1005 | event!(target: "foo_events" , parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); |
1006 | event!(target: "foo_events" , parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,); |
1007 | event!(target: "foo_events" , parent: &p, Level::DEBUG, "foo" ); |
1008 | event!(target: "foo_events" , parent: &p, Level::DEBUG, "foo: {}" , 3); |
1009 | event!(target: "foo_events" , parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
1010 | event!(target: "foo_events" , parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1011 | event!(target: "foo_events" , parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1012 | event!(target: "foo_events" , parent: &p, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux" ); |
1013 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); |
1014 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,); |
1015 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, "foo" ); |
1016 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, "foo: {}" , 3); |
1017 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux" ); |
1018 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1019 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1020 | event!(name: "foo" , target: "foo_events" , parent: &p, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux" ); |
1021 | } |
1022 | |
1023 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1024 | #[test] |
1025 | fn trace_with_parent() { |
1026 | let p = span!(Level::TRACE, "im_a_parent!" ); |
1027 | trace!(parent: &p, foo = ?3, bar.baz = %2, quux = false); |
1028 | trace!(parent: &p, foo = 3, bar.baz = 2, quux = false); |
1029 | trace!(parent: &p, foo = 3, bar.baz = 3,); |
1030 | trace!(parent: &p, "foo" ); |
1031 | trace!(parent: &p, "foo: {}" , 3); |
1032 | trace!(parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1033 | trace!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1034 | trace!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1035 | trace!(parent: &p, { foo = 2, bar.baz = 78 }, "quux" ); |
1036 | trace!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux" ); |
1037 | trace!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1038 | trace!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1039 | trace!(target: "foo_events" , parent: &p, "foo" ); |
1040 | trace!(target: "foo_events" , parent: &p, "foo: {}" , 3); |
1041 | trace!(target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1042 | trace!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1043 | trace!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1044 | trace!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1045 | trace!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1046 | trace!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1047 | trace!(name: "foo" , target: "foo_events" , parent: &p, "foo" ); |
1048 | trace!(name: "foo" , target: "foo_events" , parent: &p, "foo: {}" , 3); |
1049 | trace!(name: "foo" , target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1050 | trace!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1051 | trace!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1052 | trace!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1053 | } |
1054 | |
1055 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1056 | #[test] |
1057 | fn debug_with_parent() { |
1058 | let p = span!(Level::TRACE, "im_a_parent!" ); |
1059 | debug!(parent: &p, foo = ?3, bar.baz = %2, quux = false); |
1060 | debug!(parent: &p, foo = 3, bar.baz = 2, quux = false); |
1061 | debug!(parent: &p, foo = 3, bar.baz = 3,); |
1062 | debug!(parent: &p, "foo" ); |
1063 | debug!(parent: &p, "foo: {}" , 3); |
1064 | debug!(parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1065 | debug!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1066 | debug!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1067 | debug!(parent: &p, { foo = 2, bar.baz = 78 }, "quux" ); |
1068 | debug!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux" ); |
1069 | debug!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1070 | debug!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1071 | debug!(target: "foo_events" , parent: &p, "foo" ); |
1072 | debug!(target: "foo_events" , parent: &p, "foo: {}" , 3); |
1073 | debug!(target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1074 | debug!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1075 | debug!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1076 | debug!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1077 | debug!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1078 | debug!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1079 | debug!(name: "foo" , target: "foo_events" , parent: &p, "foo" ); |
1080 | debug!(name: "foo" , target: "foo_events" , parent: &p, "foo: {}" , 3); |
1081 | debug!(name: "foo" , target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1082 | debug!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1083 | debug!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1084 | debug!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1085 | } |
1086 | |
1087 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1088 | #[test] |
1089 | fn info_with_parent() { |
1090 | let p = span!(Level::TRACE, "im_a_parent!" ); |
1091 | info!(parent: &p, foo = ?3, bar.baz = %2, quux = false); |
1092 | info!(parent: &p, foo = 3, bar.baz = 2, quux = false); |
1093 | info!(parent: &p, foo = 3, bar.baz = 3,); |
1094 | info!(parent: &p, "foo" ); |
1095 | info!(parent: &p, "foo: {}" , 3); |
1096 | info!(parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1097 | info!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1098 | info!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1099 | info!(parent: &p, { foo = 2, bar.baz = 78 }, "quux" ); |
1100 | info!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux" ); |
1101 | info!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1102 | info!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1103 | info!(target: "foo_events" , parent: &p, "foo" ); |
1104 | info!(target: "foo_events" , parent: &p, "foo: {}" , 3); |
1105 | info!(target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1106 | info!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1107 | info!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1108 | info!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1109 | info!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1110 | info!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1111 | info!(name: "foo" , target: "foo_events" , parent: &p, "foo" ); |
1112 | info!(name: "foo" , target: "foo_events" , parent: &p, "foo: {}" , 3); |
1113 | info!(name: "foo" , target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1114 | info!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1115 | info!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1116 | info!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1117 | } |
1118 | |
1119 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1120 | #[test] |
1121 | fn warn_with_parent() { |
1122 | let p = span!(Level::TRACE, "im_a_parent!" ); |
1123 | warn!(parent: &p, foo = ?3, bar.baz = %2, quux = false); |
1124 | warn!(parent: &p, foo = 3, bar.baz = 2, quux = false); |
1125 | warn!(parent: &p, foo = 3, bar.baz = 3,); |
1126 | warn!(parent: &p, "foo" ); |
1127 | warn!(parent: &p, "foo: {}" , 3); |
1128 | warn!(parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1129 | warn!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1130 | warn!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1131 | warn!(parent: &p, { foo = 2, bar.baz = 78 }, "quux" ); |
1132 | warn!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux" ); |
1133 | warn!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1134 | warn!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1135 | warn!(target: "foo_events" , parent: &p, "foo" ); |
1136 | warn!(target: "foo_events" , parent: &p, "foo: {}" , 3); |
1137 | warn!(target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1138 | warn!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1139 | warn!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1140 | warn!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1141 | warn!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1142 | warn!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1143 | warn!(name: "foo" , target: "foo_events" , parent: &p, "foo" ); |
1144 | warn!(name: "foo" , target: "foo_events" , parent: &p, "foo: {}" , 3); |
1145 | warn!(name: "foo" , target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1146 | warn!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1147 | warn!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1148 | warn!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1149 | } |
1150 | |
1151 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1152 | #[test] |
1153 | fn error_with_parent() { |
1154 | let p = span!(Level::TRACE, "im_a_parent!" ); |
1155 | error!(parent: &p, foo = ?3, bar.baz = %2, quux = false); |
1156 | error!(parent: &p, foo = 3, bar.baz = 2, quux = false); |
1157 | error!(parent: &p, foo = 3, bar.baz = 3,); |
1158 | error!(parent: &p, "foo" ); |
1159 | error!(parent: &p, "foo: {}" , 3); |
1160 | error!(parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1161 | error!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1162 | error!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1163 | error!(parent: &p, { foo = 2, bar.baz = 78 }, "quux" ); |
1164 | error!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux" ); |
1165 | error!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1166 | error!(target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1167 | error!(target: "foo_events" , parent: &p, "foo" ); |
1168 | error!(target: "foo_events" , parent: &p, "foo: {}" , 3); |
1169 | error!(target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1170 | error!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1171 | error!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1172 | error!(target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1173 | error!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 2, quux = false); |
1174 | error!(name: "foo" , target: "foo_events" , parent: &p, foo = 3, bar.baz = 3,); |
1175 | error!(name: "foo" , target: "foo_events" , parent: &p, "foo" ); |
1176 | error!(name: "foo" , target: "foo_events" , parent: &p, "foo: {}" , 3); |
1177 | error!(name: "foo" , target: "foo_events" , parent: &p, { foo = 3, bar.baz = 80 }, "quux" ); |
1178 | error!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}" , true); |
1179 | error!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}" , true, quux = false); |
1180 | error!(name: "foo" , target: "foo_events" , parent: &p, { foo = 2, bar.baz = 78, }, "quux" ); |
1181 | } |
1182 | |
1183 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1184 | #[test] |
1185 | fn field_shorthand_only() { |
1186 | #[derive(Debug)] |
1187 | struct Position { |
1188 | x: f32, |
1189 | y: f32, |
1190 | } |
1191 | let pos = Position { |
1192 | x: 3.234, |
1193 | y: -1.223, |
1194 | }; |
1195 | |
1196 | trace!(?pos.x, ?pos.y); |
1197 | debug!(?pos.x, ?pos.y); |
1198 | info!(?pos.x, ?pos.y); |
1199 | warn!(?pos.x, ?pos.y); |
1200 | error!(?pos.x, ?pos.y); |
1201 | event!(Level::TRACE, ?pos.x, ?pos.y); |
1202 | } |
1203 | |
1204 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1205 | #[test] |
1206 | fn borrow_val_events() { |
1207 | // Reproduces https://github.com/tokio-rs/tracing/issues/954 |
1208 | let mut foo = (::std::string::String::new(), ::std::string::String::new()); |
1209 | let zero = &mut foo.0; |
1210 | trace!(one = ?foo.1); |
1211 | debug!(one = ?foo.1); |
1212 | info!(one = ?foo.1); |
1213 | warn!(one = ?foo.1); |
1214 | error!(one = ?foo.1); |
1215 | zero.push_str("hello world" ); |
1216 | } |
1217 | |
1218 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1219 | #[test] |
1220 | fn borrow_val_spans() { |
1221 | // Reproduces https://github.com/tokio-rs/tracing/issues/954 |
1222 | let mut foo = (::std::string::String::new(), ::std::string::String::new()); |
1223 | let zero = &mut foo.0; |
1224 | let _span = trace_span!("span" , one = ?foo.1); |
1225 | let _span = debug_span!("span" , one = ?foo.1); |
1226 | let _span = info_span!("span" , one = ?foo.1); |
1227 | let _span = warn_span!("span" , one = ?foo.1); |
1228 | let _span = error_span!("span" , one = ?foo.1); |
1229 | zero.push_str("hello world" ); |
1230 | } |
1231 | |
1232 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1233 | #[test] |
1234 | fn callsite_macro_api() { |
1235 | // This test should catch any inadvertent breaking changes |
1236 | // caused by changes to the macro. |
1237 | let _callsite = callsite! { |
1238 | name: "test callsite" , |
1239 | kind: tracing::metadata::Kind::EVENT, |
1240 | target: "test target" , |
1241 | level: tracing::Level::TRACE, |
1242 | fields: foo, bar, |
1243 | }; |
1244 | let _callsite = callsite! { |
1245 | name: "test callsite" , |
1246 | kind: tracing::metadata::Kind::SPAN, |
1247 | level: tracing::Level::TRACE, |
1248 | fields: foo, |
1249 | }; |
1250 | let _callsite = callsite! { |
1251 | name: "test callsite" , |
1252 | kind: tracing::metadata::Kind::SPAN, |
1253 | fields: foo, |
1254 | }; |
1255 | } |
1256 | |
1257 | #[cfg_attr (target_arch = "wasm32" , wasm_bindgen_test::wasm_bindgen_test)] |
1258 | #[test] |
1259 | fn format_args_already_defined() { |
1260 | // Reproduces: https://github.com/tokio-rs/tracing/issues/2721 |
1261 | #[allow (unused)] |
1262 | macro_rules! format_args { |
1263 | ($i:expr) => {}; |
1264 | } |
1265 | event!(Level::DEBUG, "foo: {}" , 3); |
1266 | trace!("foo: {}" , 3); |
1267 | debug!("foo: {}" , 3); |
1268 | info!("foo: {}" , 3); |
1269 | warn!("foo: {}" , 3); |
1270 | error!("foo: {}" , 3); |
1271 | } |
1272 | |