-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger_core_test.go
81 lines (67 loc) · 1.69 KB
/
logger_core_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
69
70
71
72
73
74
75
76
77
78
79
80
81
package log
import (
"github.com/echocat/slf4g/fields"
"github.com/echocat/slf4g/level"
)
func newMockCoreLogger(name string) *mockCoreLogger {
return &mockCoreLogger{
name: name,
provider: newMockProvider("mocked"),
}
}
type mockCoreLogger struct {
name string
provider *mockProvider
level level.Level
loggedEvents *[]Event
}
func (instance *mockCoreLogger) initLoggedEvents() {
instance.loggedEvents = new([]Event)
}
func (instance *mockCoreLogger) loggedEvent(i int) Event {
return (*instance.loggedEvents)[i]
}
func (instance *mockCoreLogger) Log(e Event, _ uint16) {
if v := instance.loggedEvents; v != nil {
*v = append(*v, e)
return
}
panic("not implemented in tests")
}
func (instance *mockCoreLogger) NewEvent(level level.Level, values map[string]interface{}) Event {
return &fallbackEvent{
provider: instance.provider,
level: level,
fields: fields.WithAll(values),
}
}
func (instance *mockCoreLogger) Accepts(e Event) bool {
return e != nil
}
func (instance *mockCoreLogger) IsLevelEnabled(l level.Level) bool {
if v := instance.level; v != 0 {
return instance.level.CompareTo(l) <= 0
}
panic("not implemented in tests")
}
func (instance *mockCoreLogger) GetName() string {
if v := instance.name; v != "" {
return v
}
panic("not implemented in tests")
}
func (instance *mockCoreLogger) GetProvider() Provider {
if v := instance.provider; v != nil {
return v
}
panic("not implemented in tests")
}
func newWrappingCoreLogger(in CoreLogger) *wrappingCoreLogger {
return &wrappingCoreLogger{in}
}
type wrappingCoreLogger struct {
CoreLogger
}
func (instance *wrappingCoreLogger) Unwrap() CoreLogger {
return instance.CoreLogger
}