-
Notifications
You must be signed in to change notification settings - Fork 17
/
seclog_test.go
executable file
·49 lines (42 loc) · 866 Bytes
/
seclog_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
package seclog_test
import (
"fmt"
"github.com/go-chassis/seclog"
"testing"
)
func TestNewLogger(t *testing.T) {
seclog.Init(seclog.Config{
LoggerLevel: "DEBUG",
LogFormatText: true,
Writers: []string{"stdout"},
LogColorMode: "auto",
})
logger := seclog.NewLogger("example")
logger.Debug("hi")
logger.Info("hi")
logger.Warn("hi")
}
func BenchmarkInit(b *testing.B) {
seclog.Init(seclog.Config{
LoggerLevel: "DEBUG",
LogFormatText: true,
Writers: []string{"stdout"},
})
logger := seclog.NewLogger("example")
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Info("test")
}
})
b.ReportAllocs()
logger.Debug("hi")
}
type w struct {
}
func (w *w) Write(p []byte) (n int, err error) {
fmt.Print("fake")
return 2, nil
}
func TestRegisterWriter(t *testing.T) {
seclog.RegisterWriter("test", &w{})
}