-
Notifications
You must be signed in to change notification settings - Fork 1
/
event_fallback.go
66 lines (54 loc) · 1.65 KB
/
event_fallback.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
package log
import (
"github.com/echocat/slf4g/fields"
"github.com/echocat/slf4g/level"
)
type fallbackEvent struct {
provider Provider
fields fields.Fields
level level.Level
}
func (instance *fallbackEvent) ForEach(consumer func(key string, value interface{}) error) error {
return instance.fields.ForEach(consumer)
}
func (instance *fallbackEvent) Get(key string) (interface{}, bool) {
return instance.fields.Get(key)
}
func (instance *fallbackEvent) Len() int {
return instance.fields.Len()
}
func (instance *fallbackEvent) GetLevel() level.Level {
return instance.level
}
func (instance *fallbackEvent) With(key string, value interface{}) Event {
return instance.with(func(s fields.Fields) fields.Fields {
return s.With(key, value)
})
}
func (instance *fallbackEvent) Withf(key string, format string, args ...interface{}) Event {
return instance.with(func(s fields.Fields) fields.Fields {
return s.Withf(key, format, args...)
})
}
func (instance *fallbackEvent) WithError(err error) Event {
return instance.with(func(s fields.Fields) fields.Fields {
return s.With(instance.provider.GetFieldKeysSpec().GetError(), err)
})
}
func (instance *fallbackEvent) WithAll(of map[string]interface{}) Event {
return instance.with(func(s fields.Fields) fields.Fields {
return s.WithAll(of)
})
}
func (instance *fallbackEvent) Without(keys ...string) Event {
return instance.with(func(s fields.Fields) fields.Fields {
return s.Without(keys...)
})
}
func (instance *fallbackEvent) with(mod func(fields.Fields) fields.Fields) Event {
return &fallbackEvent{
provider: instance.provider,
fields: mod(instance.fields),
level: instance.level,
}
}