-
Notifications
You must be signed in to change notification settings - Fork 0
/
zerolog_test.go
55 lines (47 loc) · 1.28 KB
/
zerolog_test.go
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
package benchmark
import (
"io/ioutil"
"testing"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
)
func TestZeroLog(t *testing.T) {
l := zerolog.New(ioutil.Discard).With().Timestamp().Logger()
l = l.Level(zerolog.Disabled)
// FIXME actually it is zerolog's disadvantage
assert.NotPanics(t, func() {
l.Panic().Msg("should panic")
})
}
func newZerolog() zerolog.Logger {
return zerolog.New(ioutil.Discard).With().Timestamp().Logger()
}
func newDisabledZerolog() zerolog.Logger {
return newZerolog().Level(zerolog.Disabled)
}
func fakeZerologFields(e *zerolog.Event) *zerolog.Event {
return e.
Int("int", _tenInts[0]).
Interface("ints", _tenInts).
Str("string", _tenStrings[0]).
Interface("strings", _tenStrings).
Time("time", _tenTimes[0]).
Interface("times", _tenTimes).
Interface("user1", _oneUser).
Interface("user2", _oneUser).
Interface("users", _tenUsers).
Err(errExample)
}
func fakeZerologContext(c zerolog.Context) zerolog.Context {
return c.
Int("int", _tenInts[0]).
Interface("ints", _tenInts).
Str("string", _tenStrings[0]).
Interface("strings", _tenStrings).
Time("time", _tenTimes[0]).
Interface("times", _tenTimes).
Interface("user1", _oneUser).
Interface("user2", _oneUser).
Interface("users", _tenUsers).
Err(errExample)
}