]>
Commit | Line | Data |
---|---|---|
f035d41b XL |
1 | #![deny(warnings)] |
2 | use tracing::Level; | |
3 | ||
4 | #[macro_use] | |
5 | extern crate tracing; | |
6 | // Tests that macros work across various invocation syntax. | |
7 | // | |
8 | // These are quite repetitive, and _could_ be generated by a macro. However, | |
9 | // they're compile-time tests, so I want to get line numbers etc out of | |
10 | // failures, and producing them with a macro would muddy the waters a bit. | |
11 | ||
5869c6ff | 12 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
13 | #[test] |
14 | fn span() { | |
15 | span!(target: "foo_events", Level::DEBUG, "foo", bar.baz = ?2, quux = %3, quuux = 4); | |
16 | span!(target: "foo_events", Level::DEBUG, "foo", bar.baz = 2, quux = 3); | |
17 | span!(target: "foo_events", Level::DEBUG, "foo", bar.baz = 2, quux = 4,); | |
18 | span!(target: "foo_events", Level::DEBUG, "foo"); | |
19 | span!(target: "foo_events", Level::DEBUG, "bar",); | |
20 | span!(Level::DEBUG, "foo", bar.baz = 2, quux = 3); | |
21 | span!(Level::DEBUG, "foo", bar.baz = 2, quux = 4,); | |
22 | span!(Level::DEBUG, "foo", bar.baz = 2, quux = 3); | |
23 | span!(Level::DEBUG, "foo", bar.baz = 2, quux = 4,); | |
24 | span!(Level::DEBUG, "foo", bar.baz = ?2); | |
25 | span!(Level::DEBUG, "foo", bar.baz = %2); | |
26 | span!(Level::DEBUG, "foo"); | |
27 | span!(Level::DEBUG, "bar",); | |
28 | } | |
29 | ||
5869c6ff | 30 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
31 | #[test] |
32 | fn trace_span() { | |
33 | trace_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4); | |
34 | trace_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3); | |
35 | trace_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,); | |
36 | trace_span!(target: "foo_events", "foo"); | |
37 | trace_span!(target: "foo_events", "bar",); | |
38 | trace_span!("foo", bar.baz = 2, quux = 3); | |
39 | trace_span!("foo", bar.baz = 2, quux = 4,); | |
40 | trace_span!("foo", bar.baz = ?2); | |
41 | trace_span!("foo", bar.baz = %2); | |
42 | trace_span!("bar"); | |
43 | trace_span!("bar",); | |
44 | } | |
45 | ||
5869c6ff | 46 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
47 | #[test] |
48 | fn debug_span() { | |
49 | debug_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4); | |
50 | debug_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3); | |
51 | debug_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,); | |
52 | debug_span!(target: "foo_events", "foo"); | |
53 | debug_span!(target: "foo_events", "bar",); | |
54 | debug_span!("foo", bar.baz = 2, quux = 3); | |
55 | debug_span!("foo", bar.baz = 2, quux = 4,); | |
56 | debug_span!("foo", bar.baz = ?2); | |
57 | debug_span!("foo", bar.baz = %2); | |
58 | debug_span!("bar"); | |
59 | debug_span!("bar",); | |
60 | } | |
61 | ||
5869c6ff | 62 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
63 | #[test] |
64 | fn info_span() { | |
65 | info_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4); | |
66 | info_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3); | |
67 | info_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,); | |
68 | info_span!(target: "foo_events", "foo"); | |
69 | info_span!(target: "foo_events", "bar",); | |
70 | info_span!("foo", bar.baz = 2, quux = 3); | |
71 | info_span!("foo", bar.baz = 2, quux = 4,); | |
72 | info_span!("foo", bar.baz = ?2); | |
73 | info_span!("foo", bar.baz = %2); | |
74 | info_span!("bar"); | |
75 | info_span!("bar",); | |
76 | } | |
77 | ||
5869c6ff | 78 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
79 | #[test] |
80 | fn warn_span() { | |
81 | warn_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4); | |
82 | warn_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3); | |
83 | warn_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,); | |
84 | warn_span!(target: "foo_events", "foo"); | |
85 | warn_span!(target: "foo_events", "bar",); | |
86 | warn_span!("foo", bar.baz = 2, quux = 3); | |
87 | warn_span!("foo", bar.baz = 2, quux = 4,); | |
88 | warn_span!("foo", bar.baz = ?2); | |
89 | warn_span!("foo", bar.baz = %2); | |
90 | warn_span!("bar"); | |
91 | warn_span!("bar",); | |
92 | } | |
93 | ||
5869c6ff | 94 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
95 | #[test] |
96 | fn error_span() { | |
97 | error_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4); | |
98 | error_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3); | |
99 | error_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,); | |
100 | error_span!(target: "foo_events", "foo"); | |
101 | error_span!(target: "foo_events", "bar",); | |
102 | error_span!("foo", bar.baz = 2, quux = 3); | |
103 | error_span!("foo", bar.baz = 2, quux = 4,); | |
104 | error_span!("foo", bar.baz = ?2); | |
105 | error_span!("foo", bar.baz = %2); | |
106 | error_span!("bar"); | |
107 | error_span!("bar",); | |
108 | } | |
109 | ||
5869c6ff | 110 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
111 | #[test] |
112 | fn span_root() { | |
113 | span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 3); | |
114 | span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 3); | |
115 | span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 4,); | |
116 | span!(target: "foo_events", parent: None, Level::TRACE, "foo"); | |
117 | span!(target: "foo_events", parent: None, Level::TRACE, "bar",); | |
118 | span!(parent: None, Level::DEBUG, "foo", bar.baz = 2, quux = 3); | |
119 | span!(parent: None, Level::DEBUG, "foo", bar.baz = 2, quux = 4,); | |
120 | span!(parent: None, Level::DEBUG, "foo"); | |
121 | span!(parent: None, Level::DEBUG, "bar",); | |
122 | } | |
123 | ||
5869c6ff | 124 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
125 | #[test] |
126 | fn trace_span_root() { | |
127 | trace_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); | |
128 | trace_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); | |
129 | trace_span!(target: "foo_events", parent: None, "foo"); | |
130 | trace_span!(target: "foo_events", parent: None, "bar",); | |
131 | trace_span!(parent: None, "foo", bar.baz = 2, quux = 3); | |
132 | trace_span!(parent: None, "foo", bar.baz = 2, quux = 4,); | |
133 | trace_span!(parent: None, "foo"); | |
134 | trace_span!(parent: None, "bar",); | |
135 | } | |
136 | ||
5869c6ff | 137 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
138 | #[test] |
139 | fn debug_span_root() { | |
140 | debug_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); | |
141 | debug_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); | |
142 | debug_span!(target: "foo_events", parent: None, "foo"); | |
143 | debug_span!(target: "foo_events", parent: None, "bar",); | |
144 | debug_span!(parent: None, "foo", bar.baz = 2, quux = 3); | |
145 | debug_span!(parent: None, "foo", bar.baz = 2, quux = 4,); | |
146 | debug_span!(parent: None, "foo"); | |
147 | debug_span!(parent: None, "bar",); | |
148 | } | |
149 | ||
5869c6ff | 150 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
151 | #[test] |
152 | fn info_span_root() { | |
153 | info_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); | |
154 | info_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); | |
155 | info_span!(target: "foo_events", parent: None, "foo"); | |
156 | info_span!(target: "foo_events", parent: None, "bar",); | |
157 | info_span!(parent: None, "foo", bar.baz = 2, quux = 3); | |
158 | info_span!(parent: None, "foo", bar.baz = 2, quux = 4,); | |
159 | info_span!(parent: None, "foo"); | |
160 | info_span!(parent: None, "bar",); | |
161 | } | |
162 | ||
5869c6ff | 163 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
164 | #[test] |
165 | fn warn_span_root() { | |
166 | warn_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); | |
167 | warn_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); | |
168 | warn_span!(target: "foo_events", parent: None, "foo"); | |
169 | warn_span!(target: "foo_events", parent: None, "bar",); | |
170 | warn_span!(parent: None, "foo", bar.baz = 2, quux = 3); | |
171 | warn_span!(parent: None, "foo", bar.baz = 2, quux = 4,); | |
172 | warn_span!(parent: None, "foo"); | |
173 | warn_span!(parent: None, "bar",); | |
174 | } | |
175 | ||
5869c6ff | 176 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
177 | #[test] |
178 | fn error_span_root() { | |
179 | error_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); | |
180 | error_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); | |
181 | error_span!(target: "foo_events", parent: None, "foo"); | |
182 | error_span!(target: "foo_events", parent: None, "bar",); | |
183 | error_span!(parent: None, "foo", bar.baz = 2, quux = 3); | |
184 | error_span!(parent: None, "foo", bar.baz = 2, quux = 4,); | |
185 | error_span!(parent: None, "foo"); | |
186 | error_span!(parent: None, "bar",); | |
187 | } | |
188 | ||
5869c6ff | 189 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
190 | #[test] |
191 | fn span_with_parent() { | |
192 | let p = span!(Level::TRACE, "im_a_parent!"); | |
193 | span!(target: "foo_events", parent: &p, Level::TRACE, "foo", bar.baz = 2, quux = 3); | |
194 | span!(target: "foo_events", parent: &p, Level::TRACE, "foo", bar.baz = 2, quux = 4,); | |
195 | span!(target: "foo_events", parent: &p, Level::TRACE, "foo"); | |
196 | span!(target: "foo_events", parent: &p, Level::TRACE, "bar",); | |
197 | span!(parent: &p, Level::DEBUG, "foo", bar.baz = 2, quux = 3); | |
198 | span!(parent: &p, Level::DEBUG, "foo", bar.baz = 2, quux = 4,); | |
199 | span!(parent: &p, Level::DEBUG, "foo"); | |
200 | span!(parent: &p, Level::DEBUG, "bar",); | |
201 | } | |
202 | ||
5869c6ff | 203 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
204 | #[test] |
205 | fn trace_span_with_parent() { | |
206 | let p = span!(Level::TRACE, "im_a_parent!"); | |
207 | trace_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3); | |
208 | trace_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,); | |
209 | trace_span!(target: "foo_events", parent: &p, "foo"); | |
210 | trace_span!(target: "foo_events", parent: &p, "bar",); | |
211 | ||
212 | trace_span!(parent: &p, "foo", bar.baz = 2, quux = 3); | |
213 | trace_span!(parent: &p, "foo", bar.baz = 2, quux = 4,); | |
214 | ||
215 | trace_span!(parent: &p, "foo"); | |
216 | trace_span!(parent: &p, "bar",); | |
217 | } | |
218 | ||
5869c6ff | 219 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
220 | #[test] |
221 | fn debug_span_with_parent() { | |
222 | let p = span!(Level::TRACE, "im_a_parent!"); | |
223 | debug_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3); | |
224 | debug_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,); | |
225 | debug_span!(target: "foo_events", parent: &p, "foo"); | |
226 | debug_span!(target: "foo_events", parent: &p, "bar",); | |
227 | ||
228 | debug_span!(parent: &p, "foo", bar.baz = 2, quux = 3); | |
229 | debug_span!(parent: &p, "foo", bar.baz = 2, quux = 4,); | |
230 | ||
231 | debug_span!(parent: &p, "foo"); | |
232 | debug_span!(parent: &p, "bar",); | |
233 | } | |
234 | ||
5869c6ff | 235 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
236 | #[test] |
237 | fn info_span_with_parent() { | |
238 | let p = span!(Level::TRACE, "im_a_parent!"); | |
239 | info_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3); | |
240 | info_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,); | |
241 | info_span!(target: "foo_events", parent: &p, "foo"); | |
242 | info_span!(target: "foo_events", parent: &p, "bar",); | |
243 | ||
244 | info_span!(parent: &p, "foo", bar.baz = 2, quux = 3); | |
245 | info_span!(parent: &p, "foo", bar.baz = 2, quux = 4,); | |
246 | ||
247 | info_span!(parent: &p, "foo"); | |
248 | info_span!(parent: &p, "bar",); | |
249 | } | |
250 | ||
5869c6ff | 251 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
252 | #[test] |
253 | fn warn_span_with_parent() { | |
254 | let p = span!(Level::TRACE, "im_a_parent!"); | |
255 | warn_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3); | |
256 | warn_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,); | |
257 | warn_span!(target: "foo_events", parent: &p, "foo"); | |
258 | warn_span!(target: "foo_events", parent: &p, "bar",); | |
259 | ||
260 | warn_span!(parent: &p, "foo", bar.baz = 2, quux = 3); | |
261 | warn_span!(parent: &p, "foo", bar.baz = 2, quux = 4,); | |
262 | ||
263 | warn_span!(parent: &p, "foo"); | |
264 | warn_span!(parent: &p, "bar",); | |
265 | } | |
266 | ||
5869c6ff | 267 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
268 | #[test] |
269 | fn error_span_with_parent() { | |
270 | let p = span!(Level::TRACE, "im_a_parent!"); | |
271 | error_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3); | |
272 | error_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,); | |
273 | error_span!(target: "foo_events", parent: &p, "foo"); | |
274 | error_span!(target: "foo_events", parent: &p, "bar",); | |
275 | ||
276 | error_span!(parent: &p, "foo", bar.baz = 2, quux = 3); | |
277 | error_span!(parent: &p, "foo", bar.baz = 2, quux = 4,); | |
278 | ||
279 | error_span!(parent: &p, "foo"); | |
280 | error_span!(parent: &p, "bar",); | |
281 | } | |
282 | ||
5869c6ff | 283 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
3dfed10e XL |
284 | #[test] |
285 | fn span_with_non_rust_symbol() { | |
286 | span!(Level::TRACE, "non-rust", "guid:x-request-id" = ?"abcdef", "more {}", 42); | |
287 | span!(Level::TRACE, "non-rust", "guid:x-request-id" = %"abcdef", "more {}", 51); | |
288 | span!( | |
289 | Level::TRACE, | |
290 | "non-rust", | |
291 | "guid:x-request-id" = "abcdef", | |
292 | "more {}", | |
293 | 60 | |
294 | ); | |
295 | span!(Level::TRACE, "non-rust", "guid:x-request-id" = ?"abcdef"); | |
296 | span!(Level::TRACE, "non-rust", "guid:x-request-id" = %"abcdef"); | |
297 | span!(Level::TRACE, "non-rust", "guid:x-request-id" = "abcdef"); | |
298 | } | |
299 | ||
5869c6ff | 300 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
301 | #[test] |
302 | fn event() { | |
303 | event!(Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); | |
304 | event!(Level::DEBUG, foo = 3, bar.baz = 2, quux = false); | |
305 | event!(Level::DEBUG, foo = 3, bar.baz = 3,); | |
306 | event!(Level::DEBUG, "foo"); | |
307 | event!(Level::DEBUG, "foo: {}", 3); | |
308 | event!(Level::INFO, foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42); | |
309 | event!( | |
310 | Level::INFO, | |
311 | foo = 3, | |
312 | bar.baz = 2, | |
313 | quux = false, | |
314 | "hello world {:?}", | |
315 | 42 | |
316 | ); | |
317 | event!(Level::INFO, foo = 3, bar.baz = 3, "hello world {:?}", 42,); | |
318 | event!(Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); | |
319 | event!(Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
320 | event!(Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
321 | event!(Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux"); | |
322 | event!(target: "foo_events", Level::DEBUG, foo = 3, bar.baz = 2, quux = false); | |
323 | event!(target: "foo_events", Level::DEBUG, foo = 3, bar.baz = 3,); | |
324 | event!(target: "foo_events", Level::DEBUG, "foo"); | |
325 | event!(target: "foo_events", Level::DEBUG, "foo: {}", 3); | |
326 | event!(target: "foo_events", Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); | |
327 | event!(target: "foo_events", Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
328 | event!(target: "foo_events", Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
329 | event!(target: "foo_events", Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); | |
330 | let foo = 1; | |
331 | event!(Level::DEBUG, ?foo); | |
332 | event!(Level::DEBUG, %foo); | |
333 | event!(Level::DEBUG, foo); | |
334 | } | |
335 | ||
5869c6ff | 336 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
337 | #[test] |
338 | fn locals_with_message() { | |
339 | let data = (42, "forty-two"); | |
340 | let private_data = "private"; | |
341 | let error = "a bad error"; | |
342 | event!(Level::ERROR, %error, "Received error"); | |
343 | event!( | |
344 | target: "app_events", | |
345 | Level::WARN, | |
346 | private_data, | |
347 | ?data, | |
348 | "App warning: {}", | |
349 | error | |
350 | ); | |
351 | } | |
352 | ||
5869c6ff | 353 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
354 | #[test] |
355 | fn locals_no_message() { | |
356 | let data = (42, "forty-two"); | |
357 | let private_data = "private"; | |
358 | let error = "a bad error"; | |
359 | event!( | |
360 | target: "app_events", | |
361 | Level::WARN, | |
362 | private_data, | |
363 | ?data, | |
364 | ); | |
365 | event!( | |
366 | target: "app_events", | |
367 | Level::WARN, | |
368 | private_data, | |
369 | ?data, | |
370 | error, | |
371 | ); | |
372 | event!( | |
373 | target: "app_events", | |
374 | Level::WARN, | |
375 | private_data, | |
376 | ?data, | |
377 | error | |
378 | ); | |
379 | event!(Level::WARN, private_data, ?data, error,); | |
380 | } | |
381 | ||
5869c6ff | 382 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
383 | #[test] |
384 | fn trace() { | |
385 | trace!(foo = ?3, bar.baz = %2, quux = false); | |
386 | trace!(foo = 3, bar.baz = 2, quux = false); | |
387 | trace!(foo = 3, bar.baz = 3,); | |
388 | trace!("foo"); | |
389 | trace!("foo: {}", 3); | |
390 | trace!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42); | |
391 | trace!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42); | |
392 | trace!(foo = 3, bar.baz = 3, "hello world {:?}", 42,); | |
393 | trace!({ foo = 3, bar.baz = 80 }, "quux"); | |
394 | trace!({ foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
395 | trace!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
396 | trace!({ foo = 2, bar.baz = 78 }, "quux"); | |
397 | trace!({ foo = ?2, bar.baz = %78 }, "quux"); | |
398 | trace!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); | |
399 | trace!(target: "foo_events", foo = 3, bar.baz = 3,); | |
400 | trace!(target: "foo_events", "foo"); | |
401 | trace!(target: "foo_events", "foo: {}", 3); | |
402 | trace!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux"); | |
403 | trace!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
404 | trace!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
405 | trace!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux"); | |
406 | let foo = 1; | |
407 | trace!(?foo); | |
408 | trace!(%foo); | |
409 | trace!(foo); | |
6a06907d XL |
410 | trace!(target: "foo_events", ?foo); |
411 | trace!(target: "foo_events", %foo); | |
412 | trace!(target: "foo_events", foo); | |
413 | trace!(target: "foo_events", ?foo, true, "message"); | |
414 | trace!(target: "foo_events", %foo, true, "message"); | |
415 | trace!(target: "foo_events", foo, true, "message"); | |
f035d41b XL |
416 | } |
417 | ||
5869c6ff | 418 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
419 | #[test] |
420 | fn debug() { | |
421 | debug!(foo = ?3, bar.baz = %2, quux = false); | |
422 | debug!(foo = 3, bar.baz = 2, quux = false); | |
423 | debug!(foo = 3, bar.baz = 3,); | |
424 | debug!("foo"); | |
425 | debug!("foo: {}", 3); | |
426 | debug!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42); | |
427 | debug!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42); | |
428 | debug!(foo = 3, bar.baz = 3, "hello world {:?}", 42,); | |
429 | debug!({ foo = 3, bar.baz = 80 }, "quux"); | |
430 | debug!({ foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
431 | debug!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
432 | debug!({ foo = 2, bar.baz = 78 }, "quux"); | |
433 | debug!({ foo = ?2, bar.baz = %78 }, "quux"); | |
434 | debug!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); | |
435 | debug!(target: "foo_events", foo = 3, bar.baz = 3,); | |
436 | debug!(target: "foo_events", "foo"); | |
437 | debug!(target: "foo_events", "foo: {}", 3); | |
438 | debug!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux"); | |
439 | debug!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
440 | debug!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
441 | debug!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux"); | |
442 | let foo = 1; | |
443 | debug!(?foo); | |
444 | debug!(%foo); | |
445 | debug!(foo); | |
6a06907d XL |
446 | debug!(target: "foo_events", ?foo); |
447 | debug!(target: "foo_events", %foo); | |
448 | debug!(target: "foo_events", foo); | |
449 | debug!(target: "foo_events", ?foo, true, "message"); | |
450 | debug!(target: "foo_events", %foo, true, "message"); | |
451 | debug!(target: "foo_events", foo, true, "message"); | |
f035d41b XL |
452 | } |
453 | ||
5869c6ff | 454 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
455 | #[test] |
456 | fn info() { | |
457 | info!(foo = ?3, bar.baz = %2, quux = false); | |
458 | info!(foo = 3, bar.baz = 2, quux = false); | |
459 | info!(foo = 3, bar.baz = 3,); | |
460 | info!("foo"); | |
461 | info!("foo: {}", 3); | |
462 | info!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42); | |
463 | info!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42); | |
464 | info!(foo = 3, bar.baz = 3, "hello world {:?}", 42,); | |
465 | info!({ foo = 3, bar.baz = 80 }, "quux"); | |
466 | info!({ foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
467 | info!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
468 | info!({ foo = 2, bar.baz = 78 }, "quux"); | |
469 | info!({ foo = ?2, bar.baz = %78 }, "quux"); | |
470 | info!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); | |
471 | info!(target: "foo_events", foo = 3, bar.baz = 3,); | |
472 | info!(target: "foo_events", "foo"); | |
473 | info!(target: "foo_events", "foo: {}", 3); | |
474 | info!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux"); | |
475 | info!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
476 | info!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
477 | info!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux"); | |
478 | let foo = 1; | |
479 | info!(?foo); | |
480 | info!(%foo); | |
481 | info!(foo); | |
6a06907d XL |
482 | info!(target: "foo_events", ?foo); |
483 | info!(target: "foo_events", %foo); | |
484 | info!(target: "foo_events", foo); | |
485 | info!(target: "foo_events", ?foo, true, "message"); | |
486 | info!(target: "foo_events", %foo, true, "message"); | |
487 | info!(target: "foo_events", foo, true, "message"); | |
f035d41b XL |
488 | } |
489 | ||
5869c6ff | 490 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
491 | #[test] |
492 | fn warn() { | |
493 | warn!(foo = ?3, bar.baz = %2, quux = false); | |
494 | warn!(foo = 3, bar.baz = 2, quux = false); | |
495 | warn!(foo = 3, bar.baz = 3,); | |
496 | warn!("foo"); | |
497 | warn!("foo: {}", 3); | |
498 | warn!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42); | |
499 | warn!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42); | |
500 | warn!(foo = 3, bar.baz = 3, "hello world {:?}", 42,); | |
501 | warn!({ foo = 3, bar.baz = 80 }, "quux"); | |
502 | warn!({ foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
503 | warn!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
504 | warn!({ foo = 2, bar.baz = 78 }, "quux"); | |
505 | warn!({ foo = ?2, bar.baz = %78 }, "quux"); | |
506 | warn!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); | |
507 | warn!(target: "foo_events", foo = 3, bar.baz = 3,); | |
508 | warn!(target: "foo_events", "foo"); | |
509 | warn!(target: "foo_events", "foo: {}", 3); | |
510 | warn!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux"); | |
511 | warn!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
512 | warn!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
513 | warn!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux"); | |
514 | let foo = 1; | |
515 | warn!(?foo); | |
516 | warn!(%foo); | |
517 | warn!(foo); | |
6a06907d XL |
518 | warn!(target: "foo_events", ?foo); |
519 | warn!(target: "foo_events", %foo); | |
520 | warn!(target: "foo_events", foo); | |
521 | warn!(target: "foo_events", ?foo, true, "message"); | |
522 | warn!(target: "foo_events", %foo, true, "message"); | |
523 | warn!(target: "foo_events", foo, true, "message"); | |
f035d41b XL |
524 | } |
525 | ||
5869c6ff | 526 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
527 | #[test] |
528 | fn error() { | |
529 | error!(foo = ?3, bar.baz = %2, quux = false); | |
530 | error!(foo = 3, bar.baz = 2, quux = false); | |
531 | error!(foo = 3, bar.baz = 3,); | |
532 | error!("foo"); | |
533 | error!("foo: {}", 3); | |
534 | error!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42); | |
535 | error!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42); | |
536 | error!(foo = 3, bar.baz = 3, "hello world {:?}", 42,); | |
537 | error!({ foo = 3, bar.baz = 80 }, "quux"); | |
538 | error!({ foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
539 | error!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
540 | error!({ foo = 2, bar.baz = 78, }, "quux"); | |
541 | error!({ foo = ?2, bar.baz = %78 }, "quux"); | |
542 | error!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); | |
543 | error!(target: "foo_events", foo = 3, bar.baz = 3,); | |
544 | error!(target: "foo_events", "foo"); | |
545 | error!(target: "foo_events", "foo: {}", 3); | |
546 | error!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux"); | |
547 | error!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
548 | error!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
549 | error!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux"); | |
550 | let foo = 1; | |
551 | error!(?foo); | |
552 | error!(%foo); | |
553 | error!(foo); | |
6a06907d XL |
554 | error!(target: "foo_events", ?foo); |
555 | error!(target: "foo_events", %foo); | |
556 | error!(target: "foo_events", foo); | |
557 | error!(target: "foo_events", ?foo, true, "message"); | |
558 | error!(target: "foo_events", %foo, true, "message"); | |
559 | error!(target: "foo_events", foo, true, "message"); | |
f035d41b XL |
560 | } |
561 | ||
5869c6ff | 562 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
563 | #[test] |
564 | fn event_root() { | |
565 | event!(parent: None, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); | |
566 | event!( | |
567 | parent: None, | |
568 | Level::DEBUG, | |
569 | foo = 3, | |
570 | bar.baz = 2, | |
571 | quux = false | |
572 | ); | |
573 | event!(parent: None, Level::DEBUG, foo = 3, bar.baz = 3,); | |
574 | event!(parent: None, Level::DEBUG, "foo"); | |
575 | event!(parent: None, Level::DEBUG, "foo: {}", 3); | |
576 | event!(parent: None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); | |
577 | event!(parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
578 | event!(parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
579 | event!(parent: None, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux"); | |
580 | event!(target: "foo_events", parent: None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); | |
581 | event!(target: "foo_events", parent: None, Level::DEBUG, foo = 3, bar.baz = 3,); | |
582 | event!(target: "foo_events", parent: None, Level::DEBUG, "foo"); | |
583 | event!(target: "foo_events", parent: None, Level::DEBUG, "foo: {}", 3); | |
584 | event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); | |
585 | event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
586 | event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
587 | event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); | |
588 | } | |
589 | ||
5869c6ff | 590 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
591 | #[test] |
592 | fn trace_root() { | |
593 | trace!(parent: None, foo = ?3, bar.baz = %2, quux = false); | |
594 | trace!(parent: None, foo = 3, bar.baz = 2, quux = false); | |
595 | trace!(parent: None, foo = 3, bar.baz = 3,); | |
596 | trace!(parent: None, "foo"); | |
597 | trace!(parent: None, "foo: {}", 3); | |
598 | trace!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
599 | trace!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
600 | trace!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
601 | trace!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); | |
602 | trace!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); | |
603 | trace!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); | |
604 | trace!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); | |
605 | trace!(target: "foo_events", parent: None, "foo"); | |
606 | trace!(target: "foo_events", parent: None, "foo: {}", 3); | |
607 | trace!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
608 | trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
609 | trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
610 | trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); | |
611 | } | |
612 | ||
5869c6ff | 613 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
614 | #[test] |
615 | fn debug_root() { | |
616 | debug!(parent: None, foo = ?3, bar.baz = %2, quux = false); | |
617 | debug!(parent: None, foo = 3, bar.baz = 2, quux = false); | |
618 | debug!(parent: None, foo = 3, bar.baz = 3,); | |
619 | debug!(parent: None, "foo"); | |
620 | debug!(parent: None, "foo: {}", 3); | |
621 | debug!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
622 | debug!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
623 | debug!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
624 | debug!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); | |
625 | debug!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); | |
626 | debug!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); | |
627 | debug!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); | |
628 | debug!(target: "foo_events", parent: None, "foo"); | |
629 | debug!(target: "foo_events", parent: None, "foo: {}", 3); | |
630 | debug!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
631 | debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
632 | debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
633 | debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); | |
634 | } | |
635 | ||
5869c6ff | 636 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
637 | #[test] |
638 | fn info_root() { | |
639 | info!(parent: None, foo = ?3, bar.baz = %2, quux = false); | |
640 | info!(parent: None, foo = 3, bar.baz = 2, quux = false); | |
641 | info!(parent: None, foo = 3, bar.baz = 3,); | |
642 | info!(parent: None, "foo"); | |
643 | info!(parent: None, "foo: {}", 3); | |
644 | info!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
645 | info!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
646 | info!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
647 | info!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); | |
648 | info!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); | |
649 | info!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); | |
650 | info!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); | |
651 | info!(target: "foo_events", parent: None, "foo"); | |
652 | info!(target: "foo_events", parent: None, "foo: {}", 3); | |
653 | info!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
654 | info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
655 | info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
656 | info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); | |
657 | } | |
658 | ||
5869c6ff | 659 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
660 | #[test] |
661 | fn warn_root() { | |
662 | warn!(parent: None, foo = ?3, bar.baz = %2, quux = false); | |
663 | warn!(parent: None, foo = 3, bar.baz = 2, quux = false); | |
664 | warn!(parent: None, foo = 3, bar.baz = 3,); | |
665 | warn!(parent: None, "foo"); | |
666 | warn!(parent: None, "foo: {}", 3); | |
667 | warn!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
668 | warn!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
669 | warn!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
670 | warn!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); | |
671 | warn!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); | |
672 | warn!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); | |
673 | warn!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); | |
674 | warn!(target: "foo_events", parent: None, "foo"); | |
675 | warn!(target: "foo_events", parent: None, "foo: {}", 3); | |
676 | warn!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
677 | warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
678 | warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
679 | warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); | |
680 | } | |
681 | ||
5869c6ff | 682 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
683 | #[test] |
684 | fn error_root() { | |
685 | error!(parent: None, foo = ?3, bar.baz = %2, quux = false); | |
686 | error!(parent: None, foo = 3, bar.baz = 2, quux = false); | |
687 | error!(parent: None, foo = 3, bar.baz = 3,); | |
688 | error!(parent: None, "foo"); | |
689 | error!(parent: None, "foo: {}", 3); | |
690 | error!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
691 | error!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
692 | error!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
693 | error!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); | |
694 | error!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); | |
695 | error!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); | |
696 | error!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); | |
697 | error!(target: "foo_events", parent: None, "foo"); | |
698 | error!(target: "foo_events", parent: None, "foo: {}", 3); | |
699 | error!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); | |
700 | error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
701 | error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
702 | error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); | |
703 | } | |
704 | ||
5869c6ff | 705 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
706 | #[test] |
707 | fn event_with_parent() { | |
708 | let p = span!(Level::TRACE, "im_a_parent!"); | |
709 | event!(parent: &p, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); | |
710 | event!(parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); | |
711 | event!(parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,); | |
712 | event!(parent: &p, Level::DEBUG, "foo"); | |
713 | event!(parent: &p, Level::DEBUG, "foo: {}", 3); | |
714 | event!(parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); | |
715 | event!(parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
716 | event!(parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
717 | event!(parent: &p, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux"); | |
718 | event!(target: "foo_events", parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); | |
719 | event!(target: "foo_events", parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,); | |
720 | event!(target: "foo_events", parent: &p, Level::DEBUG, "foo"); | |
721 | event!(target: "foo_events", parent: &p, Level::DEBUG, "foo: {}", 3); | |
722 | event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); | |
723 | event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
724 | event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
725 | event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); | |
726 | } | |
727 | ||
5869c6ff | 728 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
729 | #[test] |
730 | fn trace_with_parent() { | |
731 | let p = span!(Level::TRACE, "im_a_parent!"); | |
732 | trace!(parent: &p, foo = ?3, bar.baz = %2, quux = false); | |
733 | trace!(parent: &p, foo = 3, bar.baz = 2, quux = false); | |
734 | trace!(parent: &p, foo = 3, bar.baz = 3,); | |
735 | trace!(parent: &p, "foo"); | |
736 | trace!(parent: &p, "foo: {}", 3); | |
737 | trace!(parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
738 | trace!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
739 | trace!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
740 | trace!(parent: &p, { foo = 2, bar.baz = 78 }, "quux"); | |
741 | trace!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux"); | |
742 | trace!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); | |
743 | trace!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); | |
744 | trace!(target: "foo_events", parent: &p, "foo"); | |
745 | trace!(target: "foo_events", parent: &p, "foo: {}", 3); | |
746 | trace!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
747 | trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
748 | trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
749 | trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); | |
750 | } | |
751 | ||
5869c6ff | 752 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
753 | #[test] |
754 | fn debug_with_parent() { | |
755 | let p = span!(Level::TRACE, "im_a_parent!"); | |
756 | debug!(parent: &p, foo = ?3, bar.baz = %2, quux = false); | |
757 | debug!(parent: &p, foo = 3, bar.baz = 2, quux = false); | |
758 | debug!(parent: &p, foo = 3, bar.baz = 3,); | |
759 | debug!(parent: &p, "foo"); | |
760 | debug!(parent: &p, "foo: {}", 3); | |
761 | debug!(parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
762 | debug!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
763 | debug!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
764 | debug!(parent: &p, { foo = 2, bar.baz = 78 }, "quux"); | |
765 | debug!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux"); | |
766 | debug!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); | |
767 | debug!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); | |
768 | debug!(target: "foo_events", parent: &p, "foo"); | |
769 | debug!(target: "foo_events", parent: &p, "foo: {}", 3); | |
770 | debug!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
771 | debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
772 | debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
773 | debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); | |
774 | } | |
775 | ||
5869c6ff | 776 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
777 | #[test] |
778 | fn info_with_parent() { | |
779 | let p = span!(Level::TRACE, "im_a_parent!"); | |
780 | info!(parent: &p, foo = ?3, bar.baz = %2, quux = false); | |
781 | info!(parent: &p, foo = 3, bar.baz = 2, quux = false); | |
782 | info!(parent: &p, foo = 3, bar.baz = 3,); | |
783 | info!(parent: &p, "foo"); | |
784 | info!(parent: &p, "foo: {}", 3); | |
785 | info!(parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
786 | info!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
787 | info!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
788 | info!(parent: &p, { foo = 2, bar.baz = 78 }, "quux"); | |
789 | info!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux"); | |
790 | info!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); | |
791 | info!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); | |
792 | info!(target: "foo_events", parent: &p, "foo"); | |
793 | info!(target: "foo_events", parent: &p, "foo: {}", 3); | |
794 | info!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
795 | info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
796 | info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
797 | info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); | |
798 | } | |
799 | ||
5869c6ff | 800 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
801 | #[test] |
802 | fn warn_with_parent() { | |
803 | let p = span!(Level::TRACE, "im_a_parent!"); | |
804 | warn!(parent: &p, foo = ?3, bar.baz = %2, quux = false); | |
805 | warn!(parent: &p, foo = 3, bar.baz = 2, quux = false); | |
806 | warn!(parent: &p, foo = 3, bar.baz = 3,); | |
807 | warn!(parent: &p, "foo"); | |
808 | warn!(parent: &p, "foo: {}", 3); | |
809 | warn!(parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
810 | warn!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
811 | warn!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
812 | warn!(parent: &p, { foo = 2, bar.baz = 78 }, "quux"); | |
813 | warn!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux"); | |
814 | warn!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); | |
815 | warn!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); | |
816 | warn!(target: "foo_events", parent: &p, "foo"); | |
817 | warn!(target: "foo_events", parent: &p, "foo: {}", 3); | |
818 | warn!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
819 | warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
820 | warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
821 | warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); | |
822 | } | |
823 | ||
5869c6ff | 824 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
825 | #[test] |
826 | fn error_with_parent() { | |
827 | let p = span!(Level::TRACE, "im_a_parent!"); | |
828 | error!(parent: &p, foo = ?3, bar.baz = %2, quux = false); | |
829 | error!(parent: &p, foo = 3, bar.baz = 2, quux = false); | |
830 | error!(parent: &p, foo = 3, bar.baz = 3,); | |
831 | error!(parent: &p, "foo"); | |
832 | error!(parent: &p, "foo: {}", 3); | |
833 | error!(parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
834 | error!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
835 | error!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
836 | error!(parent: &p, { foo = 2, bar.baz = 78 }, "quux"); | |
837 | error!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux"); | |
838 | error!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); | |
839 | error!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); | |
840 | error!(target: "foo_events", parent: &p, "foo"); | |
841 | error!(target: "foo_events", parent: &p, "foo: {}", 3); | |
842 | error!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); | |
843 | error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); | |
844 | error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); | |
845 | error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); | |
846 | } | |
847 | ||
5869c6ff | 848 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
f035d41b XL |
849 | #[test] |
850 | fn field_shorthand_only() { | |
851 | #[derive(Debug)] | |
852 | struct Position { | |
853 | x: f32, | |
854 | y: f32, | |
855 | } | |
856 | let pos = Position { | |
857 | x: 3.234, | |
858 | y: -1.223, | |
859 | }; | |
860 | ||
861 | trace!(?pos.x, ?pos.y); | |
862 | debug!(?pos.x, ?pos.y); | |
863 | info!(?pos.x, ?pos.y); | |
864 | warn!(?pos.x, ?pos.y); | |
865 | error!(?pos.x, ?pos.y); | |
866 | event!(Level::TRACE, ?pos.x, ?pos.y); | |
867 | } | |
868 | ||
5869c6ff XL |
869 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] |
870 | #[test] | |
871 | fn borrow_val_events() { | |
872 | // Reproduces https://github.com/tokio-rs/tracing/issues/954 | |
873 | let mut foo = (String::new(), String::new()); | |
874 | let zero = &mut foo.0; | |
875 | trace!(one = ?foo.1); | |
876 | debug!(one = ?foo.1); | |
877 | info!(one = ?foo.1); | |
878 | warn!(one = ?foo.1); | |
879 | error!(one = ?foo.1); | |
880 | zero.push_str("hello world"); | |
881 | } | |
882 | ||
883 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] | |
884 | #[test] | |
885 | fn borrow_val_spans() { | |
886 | // Reproduces https://github.com/tokio-rs/tracing/issues/954 | |
887 | let mut foo = (String::new(), String::new()); | |
888 | let zero = &mut foo.0; | |
889 | let _span = trace_span!("span", one = ?foo.1); | |
890 | let _span = debug_span!("span", one = ?foo.1); | |
891 | let _span = info_span!("span", one = ?foo.1); | |
892 | let _span = warn_span!("span", one = ?foo.1); | |
893 | let _span = error_span!("span", one = ?foo.1); | |
894 | zero.push_str("hello world"); | |
895 | } | |
896 | ||
897 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] | |
f035d41b XL |
898 | #[test] |
899 | fn callsite_macro_api() { | |
900 | // This test should catch any inadvertent breaking changes | |
901 | // caused by changes to the macro. | |
902 | let _callsite = callsite! { | |
903 | name: "test callsite", | |
904 | kind: tracing::metadata::Kind::EVENT, | |
905 | target: "test target", | |
906 | level: tracing::Level::TRACE, | |
907 | fields: foo, bar, | |
908 | }; | |
909 | let _callsite = callsite! { | |
910 | name: "test callsite", | |
911 | kind: tracing::metadata::Kind::SPAN, | |
912 | level: tracing::Level::TRACE, | |
913 | fields: foo, | |
914 | }; | |
915 | let _callsite = callsite! { | |
916 | name: "test callsite", | |
917 | kind: tracing::metadata::Kind::SPAN, | |
918 | fields: foo, | |
919 | }; | |
920 | } |