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

// Tests that macros work across various invocation syntax.
//
// These are quite repetitive, and _could_ be generated by a macro. However,
// they're compile-time tests, so I want to get line numbers etc out of
// failures, and producing them with a macro would muddy the waters a bit.

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn span() {
    span!(target: "foo_events", Level::DEBUG, "foo", bar.baz = ?2, quux = %3, quuux = 4);
    span!(target: "foo_events", Level::DEBUG, "foo", bar.baz = 2, quux = 3);
    span!(target: "foo_events", Level::DEBUG, "foo", bar.baz = 2, quux = 4,);
    span!(target: "foo_events", Level::DEBUG, "foo");
    span!(target: "foo_events", Level::DEBUG, "bar",);
    span!(Level::DEBUG, "foo", bar.baz = 2, quux = 3);
    span!(Level::DEBUG, "foo", bar.baz = 2, quux = 4,);
    span!(Level::DEBUG, "foo", bar.baz = 2, quux = 3);
    span!(Level::DEBUG, "foo", bar.baz = 2, quux = 4,);
    span!(Level::DEBUG, "foo", bar.baz = ?2);
    span!(Level::DEBUG, "foo", bar.baz = %2);
    span!(Level::DEBUG, "foo");
    span!(Level::DEBUG, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn trace_span() {
    trace_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4);
    trace_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3);
    trace_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,);
    trace_span!(target: "foo_events", "foo");
    trace_span!(target: "foo_events", "bar",);
    trace_span!("foo", bar.baz = 2, quux = 3);
    trace_span!("foo", bar.baz = 2, quux = 4,);
    trace_span!("foo", bar.baz = ?2);
    trace_span!("foo", bar.baz = %2);
    trace_span!("bar");
    trace_span!("bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn debug_span() {
    debug_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4);
    debug_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3);
    debug_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,);
    debug_span!(target: "foo_events", "foo");
    debug_span!(target: "foo_events", "bar",);
    debug_span!("foo", bar.baz = 2, quux = 3);
    debug_span!("foo", bar.baz = 2, quux = 4,);
    debug_span!("foo", bar.baz = ?2);
    debug_span!("foo", bar.baz = %2);
    debug_span!("bar");
    debug_span!("bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn info_span() {
    info_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4);
    info_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3);
    info_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,);
    info_span!(target: "foo_events", "foo");
    info_span!(target: "foo_events", "bar",);
    info_span!("foo", bar.baz = 2, quux = 3);
    info_span!("foo", bar.baz = 2, quux = 4,);
    info_span!("foo", bar.baz = ?2);
    info_span!("foo", bar.baz = %2);
    info_span!("bar");
    info_span!("bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn warn_span() {
    warn_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4);
    warn_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3);
    warn_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,);
    warn_span!(target: "foo_events", "foo");
    warn_span!(target: "foo_events", "bar",);
    warn_span!("foo", bar.baz = 2, quux = 3);
    warn_span!("foo", bar.baz = 2, quux = 4,);
    warn_span!("foo", bar.baz = ?2);
    warn_span!("foo", bar.baz = %2);
    warn_span!("bar");
    warn_span!("bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn error_span() {
    error_span!(target: "foo_events", "foo", bar.baz = ?2, quux = %3, quuux = 4);
    error_span!(target: "foo_events", "foo", bar.baz = 2, quux = 3);
    error_span!(target: "foo_events", "foo", bar.baz = 2, quux = 4,);
    error_span!(target: "foo_events", "foo");
    error_span!(target: "foo_events", "bar",);
    error_span!("foo", bar.baz = 2, quux = 3);
    error_span!("foo", bar.baz = 2, quux = 4,);
    error_span!("foo", bar.baz = ?2);
    error_span!("foo", bar.baz = %2);
    error_span!("bar");
    error_span!("bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn span_root() {
    span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 3);
    span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 3);
    span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 4,);
    span!(target: "foo_events", parent: None, Level::TRACE, "foo");
    span!(target: "foo_events", parent: None, Level::TRACE, "bar",);
    span!(parent: None, Level::DEBUG, "foo", bar.baz = 2, quux = 3);
    span!(parent: None, Level::DEBUG, "foo", bar.baz = 2, quux = 4,);
    span!(parent: None, Level::DEBUG, "foo");
    span!(parent: None, Level::DEBUG, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn trace_span_root() {
    trace_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3);
    trace_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,);
    trace_span!(target: "foo_events", parent: None, "foo");
    trace_span!(target: "foo_events", parent: None, "bar",);
    trace_span!(parent: None, "foo", bar.baz = 2, quux = 3);
    trace_span!(parent: None, "foo", bar.baz = 2, quux = 4,);
    trace_span!(parent: None, "foo");
    trace_span!(parent: None, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn debug_span_root() {
    debug_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3);
    debug_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,);
    debug_span!(target: "foo_events", parent: None, "foo");
    debug_span!(target: "foo_events", parent: None, "bar",);
    debug_span!(parent: None, "foo", bar.baz = 2, quux = 3);
    debug_span!(parent: None, "foo", bar.baz = 2, quux = 4,);
    debug_span!(parent: None, "foo");
    debug_span!(parent: None, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn info_span_root() {
    info_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3);
    info_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,);
    info_span!(target: "foo_events", parent: None, "foo");
    info_span!(target: "foo_events", parent: None, "bar",);
    info_span!(parent: None, "foo", bar.baz = 2, quux = 3);
    info_span!(parent: None, "foo", bar.baz = 2, quux = 4,);
    info_span!(parent: None, "foo");
    info_span!(parent: None, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn warn_span_root() {
    warn_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3);
    warn_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,);
    warn_span!(target: "foo_events", parent: None, "foo");
    warn_span!(target: "foo_events", parent: None, "bar",);
    warn_span!(parent: None, "foo", bar.baz = 2, quux = 3);
    warn_span!(parent: None, "foo", bar.baz = 2, quux = 4,);
    warn_span!(parent: None, "foo");
    warn_span!(parent: None, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn error_span_root() {
    error_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3);
    error_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,);
    error_span!(target: "foo_events", parent: None, "foo");
    error_span!(target: "foo_events", parent: None, "bar",);
    error_span!(parent: None, "foo", bar.baz = 2, quux = 3);
    error_span!(parent: None, "foo", bar.baz = 2, quux = 4,);
    error_span!(parent: None, "foo");
    error_span!(parent: None, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn span_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    span!(target: "foo_events", parent: &p, Level::TRACE, "foo", bar.baz = 2, quux = 3);
    span!(target: "foo_events", parent: &p, Level::TRACE, "foo", bar.baz = 2, quux = 4,);
    span!(target: "foo_events", parent: &p, Level::TRACE, "foo");
    span!(target: "foo_events", parent: &p, Level::TRACE, "bar",);
    span!(parent: &p, Level::DEBUG, "foo", bar.baz = 2, quux = 3);
    span!(parent: &p, Level::DEBUG, "foo", bar.baz = 2, quux = 4,);
    span!(parent: &p, Level::DEBUG, "foo");
    span!(parent: &p, Level::DEBUG, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn trace_span_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    trace_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3);
    trace_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,);
    trace_span!(target: "foo_events", parent: &p, "foo");
    trace_span!(target: "foo_events", parent: &p, "bar",);

    trace_span!(parent: &p, "foo", bar.baz = 2, quux = 3);
    trace_span!(parent: &p, "foo", bar.baz = 2, quux = 4,);

    trace_span!(parent: &p, "foo");
    trace_span!(parent: &p, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn debug_span_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    debug_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3);
    debug_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,);
    debug_span!(target: "foo_events", parent: &p, "foo");
    debug_span!(target: "foo_events", parent: &p, "bar",);

    debug_span!(parent: &p, "foo", bar.baz = 2, quux = 3);
    debug_span!(parent: &p, "foo", bar.baz = 2, quux = 4,);

    debug_span!(parent: &p, "foo");
    debug_span!(parent: &p, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn info_span_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    info_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3);
    info_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,);
    info_span!(target: "foo_events", parent: &p, "foo");
    info_span!(target: "foo_events", parent: &p, "bar",);

    info_span!(parent: &p, "foo", bar.baz = 2, quux = 3);
    info_span!(parent: &p, "foo", bar.baz = 2, quux = 4,);

    info_span!(parent: &p, "foo");
    info_span!(parent: &p, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn warn_span_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    warn_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3);
    warn_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,);
    warn_span!(target: "foo_events", parent: &p, "foo");
    warn_span!(target: "foo_events", parent: &p, "bar",);

    warn_span!(parent: &p, "foo", bar.baz = 2, quux = 3);
    warn_span!(parent: &p, "foo", bar.baz = 2, quux = 4,);

    warn_span!(parent: &p, "foo");
    warn_span!(parent: &p, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn error_span_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    error_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 3);
    error_span!(target: "foo_events", parent: &p, "foo", bar.baz = 2, quux = 4,);
    error_span!(target: "foo_events", parent: &p, "foo");
    error_span!(target: "foo_events", parent: &p, "bar",);

    error_span!(parent: &p, "foo", bar.baz = 2, quux = 3);
    error_span!(parent: &p, "foo", bar.baz = 2, quux = 4,);

    error_span!(parent: &p, "foo");
    error_span!(parent: &p, "bar",);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn span_with_non_rust_symbol() {
    span!(Level::TRACE, "non-rust", "guid:x-request-id" = ?"abcdef", "more {}", 42);
    span!(Level::TRACE, "non-rust", "guid:x-request-id" = %"abcdef", "more {}", 51);
    span!(
        Level::TRACE,
        "non-rust",
        "guid:x-request-id" = "abcdef",
        "more {}",
        60
    );
    span!(Level::TRACE, "non-rust", "guid:x-request-id" = ?"abcdef");
    span!(Level::TRACE, "non-rust", "guid:x-request-id" = %"abcdef");
    span!(Level::TRACE, "non-rust", "guid:x-request-id" = "abcdef");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn event() {
    event!(Level::DEBUG, foo = ?3, bar.baz = %2, quux = false);
    event!(Level::DEBUG, foo = 3, bar.baz = 2, quux = false);
    event!(Level::DEBUG, foo = 3, bar.baz = 3,);
    event!(Level::DEBUG, "foo");
    event!(Level::DEBUG, "foo: {}", 3);
    event!(Level::INFO, foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42);
    event!(
        Level::INFO,
        foo = 3,
        bar.baz = 2,
        quux = false,
        "hello world {:?}",
        42
    );
    event!(Level::INFO, foo = 3, bar.baz = 3, "hello world {:?}", 42,);
    event!(Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux");
    event!(Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    event!(Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    event!(Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux");
    event!(target: "foo_events", Level::DEBUG, foo = 3, bar.baz = 2, quux = false);
    event!(target: "foo_events", Level::DEBUG, foo = 3, bar.baz = 3,);
    event!(target: "foo_events", Level::DEBUG, "foo");
    event!(target: "foo_events", Level::DEBUG, "foo: {}", 3);
    event!(target: "foo_events", Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux");
    event!(target: "foo_events", Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    event!(target: "foo_events", Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    event!(target: "foo_events", Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux");
    let foo = 1;
    event!(Level::DEBUG, ?foo);
    event!(Level::DEBUG, %foo);
    event!(Level::DEBUG, foo);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn enabled() {
    enabled!(Level::DEBUG, foo, bar.baz, quux,);
    enabled!(Level::DEBUG, message);
    enabled!(Level::INFO, foo, bar.baz, quux, message,);
    enabled!(Level::INFO, foo, bar., message,);
    enabled!(Level::DEBUG, foo);

    enabled!(Level::DEBUG);
    enabled!(target: "rando", Level::DEBUG);
    enabled!(target: "rando", Level::DEBUG, field);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn span_enabled() {
    span_enabled!(Level::DEBUG, foo, bar.baz, quux,);
    span_enabled!(Level::DEBUG, message);
    span_enabled!(Level::INFO, foo, bar.baz, quux, message,);
    span_enabled!(Level::INFO, foo, bar., message,);
    span_enabled!(Level::DEBUG, foo);

    span_enabled!(Level::DEBUG);
    span_enabled!(target: "rando", Level::DEBUG);
    span_enabled!(target: "rando", Level::DEBUG, field);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn event_enabled() {
    event_enabled!(Level::DEBUG, foo, bar.baz, quux,);
    event_enabled!(Level::DEBUG, message);
    event_enabled!(Level::INFO, foo, bar.baz, quux, message,);
    event_enabled!(Level::INFO, foo, bar., message,);
    event_enabled!(Level::DEBUG, foo);

    event_enabled!(Level::DEBUG);
    event_enabled!(target: "rando", Level::DEBUG);
    event_enabled!(target: "rando", Level::DEBUG, field);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn locals_with_message() {
    let data = (42, "forty-two");
    let private_data = "private";
    let error = "a bad error";
    event!(Level::ERROR, %error, "Received error");
    event!(
        target: "app_events",
        Level::WARN,
        private_data,
        ?data,
        "App warning: {}",
        error
    );
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn locals_no_message() {
    let data = (42, "forty-two");
    let private_data = "private";
    let error = "a bad error";
    event!(
        target: "app_events",
        Level::WARN,
        private_data,
        ?data,
    );
    event!(
        target: "app_events",
        Level::WARN,
        private_data,
        ?data,
        error,
    );
    event!(
        target: "app_events",
        Level::WARN,
        private_data,
        ?data,
        error
    );
    event!(Level::WARN, private_data, ?data, error,);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn trace() {
    trace!(foo = ?3, bar.baz = %2, quux = false);
    trace!(foo = 3, bar.baz = 2, quux = false);
    trace!(foo = 3, bar.baz = 3,);
    trace!("foo");
    trace!("foo: {}", 3);
    trace!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42);
    trace!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42);
    trace!(foo = 3, bar.baz = 3, "hello world {:?}", 42,);
    trace!({ foo = 3, bar.baz = 80 }, "quux");
    trace!({ foo = 2, bar.baz = 79 }, "quux {:?}", true);
    trace!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    trace!({ foo = 2, bar.baz = 78 }, "quux");
    trace!({ foo = ?2, bar.baz = %78 }, "quux");
    trace!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
    trace!(target: "foo_events", foo = 3, bar.baz = 3,);
    trace!(target: "foo_events", "foo");
    trace!(target: "foo_events", "foo: {}", 3);
    trace!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux");
    trace!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    trace!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    trace!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux");
    let foo = 1;
    trace!(?foo);
    trace!(%foo);
    trace!(foo);
    trace!(target: "foo_events", ?foo);
    trace!(target: "foo_events", %foo);
    trace!(target: "foo_events", foo);
    trace!(target: "foo_events", ?foo, true, "message");
    trace!(target: "foo_events", %foo, true, "message");
    trace!(target: "foo_events", foo, true, "message");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn debug() {
    debug!(foo = ?3, bar.baz = %2, quux = false);
    debug!(foo = 3, bar.baz = 2, quux = false);
    debug!(foo = 3, bar.baz = 3,);
    debug!("foo");
    debug!("foo: {}", 3);
    debug!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42);
    debug!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42);
    debug!(foo = 3, bar.baz = 3, "hello world {:?}", 42,);
    debug!({ foo = 3, bar.baz = 80 }, "quux");
    debug!({ foo = 2, bar.baz = 79 }, "quux {:?}", true);
    debug!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    debug!({ foo = 2, bar.baz = 78 }, "quux");
    debug!({ foo = ?2, bar.baz = %78 }, "quux");
    debug!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
    debug!(target: "foo_events", foo = 3, bar.baz = 3,);
    debug!(target: "foo_events", "foo");
    debug!(target: "foo_events", "foo: {}", 3);
    debug!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux");
    debug!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    debug!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    debug!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux");
    let foo = 1;
    debug!(?foo);
    debug!(%foo);
    debug!(foo);
    debug!(target: "foo_events", ?foo);
    debug!(target: "foo_events", %foo);
    debug!(target: "foo_events", foo);
    debug!(target: "foo_events", ?foo, true, "message");
    debug!(target: "foo_events", %foo, true, "message");
    debug!(target: "foo_events", foo, true, "message");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn info() {
    info!(foo = ?3, bar.baz = %2, quux = false);
    info!(foo = 3, bar.baz = 2, quux = false);
    info!(foo = 3, bar.baz = 3,);
    info!("foo");
    info!("foo: {}", 3);
    info!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42);
    info!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42);
    info!(foo = 3, bar.baz = 3, "hello world {:?}", 42,);
    info!({ foo = 3, bar.baz = 80 }, "quux");
    info!({ foo = 2, bar.baz = 79 }, "quux {:?}", true);
    info!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    info!({ foo = 2, bar.baz = 78 }, "quux");
    info!({ foo = ?2, bar.baz = %78 }, "quux");
    info!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
    info!(target: "foo_events", foo = 3, bar.baz = 3,);
    info!(target: "foo_events", "foo");
    info!(target: "foo_events", "foo: {}", 3);
    info!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux");
    info!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    info!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    info!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux");
    let foo = 1;
    info!(?foo);
    info!(%foo);
    info!(foo);
    info!(target: "foo_events", ?foo);
    info!(target: "foo_events", %foo);
    info!(target: "foo_events", foo);
    info!(target: "foo_events", ?foo, true, "message");
    info!(target: "foo_events", %foo, true, "message");
    info!(target: "foo_events", foo, true, "message");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn warn() {
    warn!(foo = ?3, bar.baz = %2, quux = false);
    warn!(foo = 3, bar.baz = 2, quux = false);
    warn!(foo = 3, bar.baz = 3,);
    warn!("foo");
    warn!("foo: {}", 3);
    warn!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42);
    warn!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42);
    warn!(foo = 3, bar.baz = 3, "hello world {:?}", 42,);
    warn!({ foo = 3, bar.baz = 80 }, "quux");
    warn!({ foo = 2, bar.baz = 79 }, "quux {:?}", true);
    warn!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    warn!({ foo = 2, bar.baz = 78 }, "quux");
    warn!({ foo = ?2, bar.baz = %78 }, "quux");
    warn!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
    warn!(target: "foo_events", foo = 3, bar.baz = 3,);
    warn!(target: "foo_events", "foo");
    warn!(target: "foo_events", "foo: {}", 3);
    warn!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux");
    warn!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    warn!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    warn!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux");
    let foo = 1;
    warn!(?foo);
    warn!(%foo);
    warn!(foo);
    warn!(target: "foo_events", ?foo);
    warn!(target: "foo_events", %foo);
    warn!(target: "foo_events", foo);
    warn!(target: "foo_events", ?foo, true, "message");
    warn!(target: "foo_events", %foo, true, "message");
    warn!(target: "foo_events", foo, true, "message");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn error() {
    error!(foo = ?3, bar.baz = %2, quux = false);
    error!(foo = 3, bar.baz = 2, quux = false);
    error!(foo = 3, bar.baz = 3,);
    error!("foo");
    error!("foo: {}", 3);
    error!(foo = ?3, bar.baz = %2, quux = false, "hello world {:?}", 42);
    error!(foo = 3, bar.baz = 2, quux = false, "hello world {:?}", 42);
    error!(foo = 3, bar.baz = 3, "hello world {:?}", 42,);
    error!({ foo = 3, bar.baz = 80 }, "quux");
    error!({ foo = 2, bar.baz = 79 }, "quux {:?}", true);
    error!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    error!({ foo = 2, bar.baz = 78, }, "quux");
    error!({ foo = ?2, bar.baz = %78 }, "quux");
    error!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
    error!(target: "foo_events", foo = 3, bar.baz = 3,);
    error!(target: "foo_events", "foo");
    error!(target: "foo_events", "foo: {}", 3);
    error!(target: "foo_events", { foo = 3, bar.baz = 80 }, "quux");
    error!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    error!(target: "foo_events", { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    error!(target: "foo_events", { foo = 2, bar.baz = 78, }, "quux");
    let foo = 1;
    error!(?foo);
    error!(%foo);
    error!(foo);
    error!(target: "foo_events", ?foo);
    error!(target: "foo_events", %foo);
    error!(target: "foo_events", foo);
    error!(target: "foo_events", ?foo, true, "message");
    error!(target: "foo_events", %foo, true, "message");
    error!(target: "foo_events", foo, true, "message");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn event_root() {
    event!(parent: None, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false);
    event!(
        parent: None,
        Level::DEBUG,
        foo = 3,
        bar.baz = 2,
        quux = false
    );
    event!(parent: None, Level::DEBUG, foo = 3, bar.baz = 3,);
    event!(parent: None, Level::DEBUG, "foo");
    event!(parent: None, Level::DEBUG, "foo: {}", 3);
    event!(parent: None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux");
    event!(parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    event!(parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    event!(parent: None, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux");
    event!(target: "foo_events", parent: None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false);
    event!(target: "foo_events", parent: None, Level::DEBUG, foo = 3, bar.baz = 3,);
    event!(target: "foo_events", parent: None, Level::DEBUG, "foo");
    event!(target: "foo_events", parent: None, Level::DEBUG, "foo: {}", 3);
    event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux");
    event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn trace_root() {
    trace!(parent: None, foo = ?3, bar.baz = %2, quux = false);
    trace!(parent: None, foo = 3, bar.baz = 2, quux = false);
    trace!(parent: None, foo = 3, bar.baz = 3,);
    trace!(parent: None, "foo");
    trace!(parent: None, "foo: {}", 3);
    trace!(parent: None, { foo = 3, bar.baz = 80 }, "quux");
    trace!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    trace!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    trace!(parent: None, { foo = 2, bar.baz = 78 }, "quux");
    trace!(parent: None, { foo = ?2, bar.baz = %78 }, "quux");
    trace!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false);
    trace!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,);
    trace!(target: "foo_events", parent: None, "foo");
    trace!(target: "foo_events", parent: None, "foo: {}", 3);
    trace!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux");
    trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn debug_root() {
    debug!(parent: None, foo = ?3, bar.baz = %2, quux = false);
    debug!(parent: None, foo = 3, bar.baz = 2, quux = false);
    debug!(parent: None, foo = 3, bar.baz = 3,);
    debug!(parent: None, "foo");
    debug!(parent: None, "foo: {}", 3);
    debug!(parent: None, { foo = 3, bar.baz = 80 }, "quux");
    debug!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    debug!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    debug!(parent: None, { foo = 2, bar.baz = 78 }, "quux");
    debug!(parent: None, { foo = ?2, bar.baz = %78 }, "quux");
    debug!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false);
    debug!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,);
    debug!(target: "foo_events", parent: None, "foo");
    debug!(target: "foo_events", parent: None, "foo: {}", 3);
    debug!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux");
    debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn info_root() {
    info!(parent: None, foo = ?3, bar.baz = %2, quux = false);
    info!(parent: None, foo = 3, bar.baz = 2, quux = false);
    info!(parent: None, foo = 3, bar.baz = 3,);
    info!(parent: None, "foo");
    info!(parent: None, "foo: {}", 3);
    info!(parent: None, { foo = 3, bar.baz = 80 }, "quux");
    info!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    info!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    info!(parent: None, { foo = 2, bar.baz = 78 }, "quux");
    info!(parent: None, { foo = ?2, bar.baz = %78 }, "quux");
    info!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false);
    info!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,);
    info!(target: "foo_events", parent: None, "foo");
    info!(target: "foo_events", parent: None, "foo: {}", 3);
    info!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux");
    info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn warn_root() {
    warn!(parent: None, foo = ?3, bar.baz = %2, quux = false);
    warn!(parent: None, foo = 3, bar.baz = 2, quux = false);
    warn!(parent: None, foo = 3, bar.baz = 3,);
    warn!(parent: None, "foo");
    warn!(parent: None, "foo: {}", 3);
    warn!(parent: None, { foo = 3, bar.baz = 80 }, "quux");
    warn!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    warn!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    warn!(parent: None, { foo = 2, bar.baz = 78 }, "quux");
    warn!(parent: None, { foo = ?2, bar.baz = %78 }, "quux");
    warn!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false);
    warn!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,);
    warn!(target: "foo_events", parent: None, "foo");
    warn!(target: "foo_events", parent: None, "foo: {}", 3);
    warn!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux");
    warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn error_root() {
    error!(parent: None, foo = ?3, bar.baz = %2, quux = false);
    error!(parent: None, foo = 3, bar.baz = 2, quux = false);
    error!(parent: None, foo = 3, bar.baz = 3,);
    error!(parent: None, "foo");
    error!(parent: None, "foo: {}", 3);
    error!(parent: None, { foo = 3, bar.baz = 80 }, "quux");
    error!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    error!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    error!(parent: None, { foo = 2, bar.baz = 78 }, "quux");
    error!(parent: None, { foo = ?2, bar.baz = %78 }, "quux");
    error!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false);
    error!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,);
    error!(target: "foo_events", parent: None, "foo");
    error!(target: "foo_events", parent: None, "foo: {}", 3);
    error!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux");
    error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn event_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    event!(parent: &p, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false);
    event!(parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false);
    event!(parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,);
    event!(parent: &p, Level::DEBUG, "foo");
    event!(parent: &p, Level::DEBUG, "foo: {}", 3);
    event!(parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux");
    event!(parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    event!(parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    event!(parent: &p, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux");
    event!(target: "foo_events", parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false);
    event!(target: "foo_events", parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,);
    event!(target: "foo_events", parent: &p, Level::DEBUG, "foo");
    event!(target: "foo_events", parent: &p, Level::DEBUG, "foo: {}", 3);
    event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux");
    event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn trace_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    trace!(parent: &p, foo = ?3, bar.baz = %2, quux = false);
    trace!(parent: &p, foo = 3, bar.baz = 2, quux = false);
    trace!(parent: &p, foo = 3, bar.baz = 3,);
    trace!(parent: &p, "foo");
    trace!(parent: &p, "foo: {}", 3);
    trace!(parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    trace!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    trace!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    trace!(parent: &p, { foo = 2, bar.baz = 78 }, "quux");
    trace!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux");
    trace!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false);
    trace!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,);
    trace!(target: "foo_events", parent: &p, "foo");
    trace!(target: "foo_events", parent: &p, "foo: {}", 3);
    trace!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn debug_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    debug!(parent: &p, foo = ?3, bar.baz = %2, quux = false);
    debug!(parent: &p, foo = 3, bar.baz = 2, quux = false);
    debug!(parent: &p, foo = 3, bar.baz = 3,);
    debug!(parent: &p, "foo");
    debug!(parent: &p, "foo: {}", 3);
    debug!(parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    debug!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    debug!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    debug!(parent: &p, { foo = 2, bar.baz = 78 }, "quux");
    debug!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux");
    debug!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false);
    debug!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,);
    debug!(target: "foo_events", parent: &p, "foo");
    debug!(target: "foo_events", parent: &p, "foo: {}", 3);
    debug!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn info_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    info!(parent: &p, foo = ?3, bar.baz = %2, quux = false);
    info!(parent: &p, foo = 3, bar.baz = 2, quux = false);
    info!(parent: &p, foo = 3, bar.baz = 3,);
    info!(parent: &p, "foo");
    info!(parent: &p, "foo: {}", 3);
    info!(parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    info!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    info!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    info!(parent: &p, { foo = 2, bar.baz = 78 }, "quux");
    info!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux");
    info!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false);
    info!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,);
    info!(target: "foo_events", parent: &p, "foo");
    info!(target: "foo_events", parent: &p, "foo: {}", 3);
    info!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn warn_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    warn!(parent: &p, foo = ?3, bar.baz = %2, quux = false);
    warn!(parent: &p, foo = 3, bar.baz = 2, quux = false);
    warn!(parent: &p, foo = 3, bar.baz = 3,);
    warn!(parent: &p, "foo");
    warn!(parent: &p, "foo: {}", 3);
    warn!(parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    warn!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    warn!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    warn!(parent: &p, { foo = 2, bar.baz = 78 }, "quux");
    warn!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux");
    warn!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false);
    warn!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,);
    warn!(target: "foo_events", parent: &p, "foo");
    warn!(target: "foo_events", parent: &p, "foo: {}", 3);
    warn!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn error_with_parent() {
    let p = span!(Level::TRACE, "im_a_parent!");
    error!(parent: &p, foo = ?3, bar.baz = %2, quux = false);
    error!(parent: &p, foo = 3, bar.baz = 2, quux = false);
    error!(parent: &p, foo = 3, bar.baz = 3,);
    error!(parent: &p, "foo");
    error!(parent: &p, "foo: {}", 3);
    error!(parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    error!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    error!(parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    error!(parent: &p, { foo = 2, bar.baz = 78 }, "quux");
    error!(parent: &p, { foo = ?2, bar.baz = %78 }, "quux");
    error!(target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false);
    error!(target: "foo_events", parent: &p, foo = 3, bar.baz = 3,);
    error!(target: "foo_events", parent: &p, "foo");
    error!(target: "foo_events", parent: &p, "foo: {}", 3);
    error!(target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux");
    error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true);
    error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false);
    error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn field_shorthand_only() {
    #[derive(Debug)]
    struct Position {
        x: f32,
        y: f32,
    }
    let pos = Position {
        x: 3.234,
        y: -1.223,
    };

    trace!(?pos.x, ?pos.y);
    debug!(?pos.x, ?pos.y);
    info!(?pos.x, ?pos.y);
    warn!(?pos.x, ?pos.y);
    error!(?pos.x, ?pos.y);
    event!(Level::TRACE, ?pos.x, ?pos.y);
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn borrow_val_events() {
    // Reproduces https://github.com/tokio-rs/tracing/issues/954
    let mut foo = (String::new(), String::new());
    let zero = &mut foo.0;
    trace!(one = ?foo.1);
    debug!(one = ?foo.1);
    info!(one = ?foo.1);
    warn!(one = ?foo.1);
    error!(one = ?foo.1);
    zero.push_str("hello world");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn borrow_val_spans() {
    // Reproduces https://github.com/tokio-rs/tracing/issues/954
    let mut foo = (String::new(), String::new());
    let zero = &mut foo.0;
    let _span = trace_span!("span", one = ?foo.1);
    let _span = debug_span!("span", one = ?foo.1);
    let _span = info_span!("span", one = ?foo.1);
    let _span = warn_span!("span", one = ?foo.1);
    let _span = error_span!("span", one = ?foo.1);
    zero.push_str("hello world");
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn callsite_macro_api() {
    // This test should catch any inadvertent breaking changes
    // caused by changes to the macro.
    let _callsite = callsite! {
        name: "test callsite",
        kind: tracing::metadata::Kind::EVENT,
        target: "test target",
        level: tracing::Level::TRACE,
        fields: foo, bar,
    };
    let _callsite = callsite! {
        name: "test callsite",
        kind: tracing::metadata::Kind::SPAN,
        level: tracing::Level::TRACE,
        fields: foo,
    };
    let _callsite = callsite! {
        name: "test callsite",
        kind: tracing::metadata::Kind::SPAN,
        fields: foo,
    };
}