-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlog15_test.go
68 lines (52 loc) · 1.25 KB
/
log15_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
56
57
58
59
60
61
62
63
64
65
66
67
68
package bench
import (
"fmt"
"io"
"github.com/inconshreveable/log15"
)
type log15Bench struct {
l log15.Logger
}
func newLog15(w io.Writer) log15.Logger {
l := log15.New()
h := log15.StreamHandler(w, log15.JsonFormat())
l.SetHandler(log15.LvlFilterHandler(log15.LvlInfo, h))
return l
}
func (b *log15Bench) new(w io.Writer) logBenchmark {
return &log15Bench{
l: newLog15(w),
}
}
func (b *log15Bench) newWithCtx(w io.Writer) logBenchmark {
return &log15Bench{
l: newLog15(w).New(alternatingKeyValuePairs()...),
}
}
func (b *log15Bench) name() string {
return "Log15"
}
func (b *log15Bench) logEvent(msg string) {
b.l.Info(msg)
}
func (b *log15Bench) logEventFmt(msg string, args ...any) {
b.l.Info(fmt.Sprintf(msg, args...))
}
func (b *log15Bench) logEventCtx(msg string) {
b.l.Info(msg, alternatingKeyValuePairs()...)
}
func (b *log15Bench) logEventCtxWeak(msg string) {
b.logEventCtx(msg)
}
func (b *log15Bench) logDisabled(msg string) {
b.l.Debug(msg)
}
func (b *log15Bench) logDisabledFmt(msg string, args ...any) {
b.l.Debug(fmt.Sprintf(msg, args...))
}
func (b *log15Bench) logDisabledCtx(msg string) {
b.l.Debug(msg, alternatingKeyValuePairs()...)
}
func (b *log15Bench) logDisabledCtxWeak(msg string) {
b.logDisabledCtx(msg)
}