...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package benchmarks
25
26 import (
27 "errors"
28 "log/slog"
29 "time"
30 )
31
32 const testMessage = "Test logging, but use a somewhat realistic message length."
33
34 type event struct {
35 ID string
36 Index int
37 Flag bool
38 }
39
40 var (
41 testTime = time.Date(2022, time.May, 1, 0, 0, 0, 0, time.UTC)
42 testString = "7e3b3b2aaeff56a7108fe11e154200dd/7819479873059528190"
43 testInt = 32768
44 testDuration = 23 * time.Second
45 testError = errors.New("fail")
46 testEvent = event{"abcdefgh", 65536, true}
47 )
48
49 var testAttrs = []slog.Attr{
50 slog.String("string", testString),
51 slog.Int("status", testInt),
52 slog.Duration("duration", testDuration),
53 slog.Time("time", testTime),
54 slog.Any("error", testError),
55 }
56
57 const wantText = "time=1651363200 level=0 msg=Test logging, but use a somewhat realistic message length. string=7e3b3b2aaeff56a7108fe11e154200dd/7819479873059528190 status=32768 duration=23000000000 time=1651363200 error=fail\n"
58
View as plain text