-
Notifications
You must be signed in to change notification settings - Fork 0
/
console_logger_test.go
50 lines (46 loc) · 1.3 KB
/
console_logger_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
package log
import (
"testing"
"github.com/no-src/log/formatter"
"github.com/no-src/log/level"
)
func TestConsoleLogger(t *testing.T) {
testCases := []struct {
name string
formatter string
concurrency bool
timeFormat string
}{
{"TextFormatter", formatter.TextFormatter, false, testTimeFormat},
{"JsonFormatter", formatter.JsonFormatter, false, testTimeFormat},
{"TextFormatter Concurrency", formatter.TextFormatter, true, ""},
{"JsonFormatter Concurrency", formatter.JsonFormatter, true, ""},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
InitDefaultLogger(NewConsoleLogger(level.DebugLevel).WithFormatter(formatter.New(tc.formatter)).WithTimeFormat(tc.timeFormat))
defer Close()
if tc.concurrency {
testLogsConcurrency(t, "TestConsoleLogger")
} else {
testLogs(t)
}
})
}
}
func TestConsoleLoggerWithBuffer(t *testing.T) {
testCases := []struct {
name string
formatter string
}{
{"TextFormatter", formatter.TextFormatter},
{"JsonFormatter", formatter.JsonFormatter},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
InitDefaultLogger(newConsoleLoggerWithBuffer(level.DebugLevel, true).WithFormatter(formatter.New(tc.formatter)).WithTimeFormat(testTimeFormat))
defer Close()
testLogs(t)
})
}
}