-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjectfields.go
102 lines (81 loc) · 2.57 KB
/
objectfields.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package logiface
import (
"encoding/base64"
"encoding/json"
"time"
)
type (
// objectFields implements Event in order to use modifierMethods
objectFields[E Event, P Parent[E]] ObjectBuilder[E, P]
)
func (x *ObjectBuilder[E, P]) methods() modifierMethods[*objectFields[E, P]] {
return modifierMethods[*objectFields[E, P]]{}
}
func (x *ObjectBuilder[E, P]) fields() *objectFields[E, P] {
return (*objectFields[E, P])(x)
}
func (x *objectFields[E, P]) builder() *ObjectBuilder[E, P] {
return (*ObjectBuilder[E, P])(x)
}
// Level is necessary to pass the various guards (they just test [Level.Enabled]).
func (x *objectFields[E, P]) Level() Level {
if x.builder().Enabled() {
return LevelEmergency
}
return LevelDisabled
}
func (x *objectFields[E, P]) AddField(key string, val any) {
x.b = x.builder().objField(x.b, key, val)
}
func (x *objectFields[E, P]) AddMessage(msg string) bool {
panic(`unimplemented`)
}
func (x *objectFields[E, P]) AddString(key string, val string) (ok bool) {
x.b, ok = x.builder().objString(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddBool(key string, val bool) (ok bool) {
x.b, ok = x.builder().objBool(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddError(err error) (ok bool) {
x.b, ok = x.builder().objError(x.b, err)
return
}
func (x *objectFields[E, P]) AddInt(key string, val int) (ok bool) {
x.b, ok = x.builder().objInt(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddFloat32(key string, val float32) (ok bool) {
x.b, ok = x.builder().objFloat32(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddTime(key string, val time.Time) (ok bool) {
x.b, ok = x.builder().objTime(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddDuration(key string, val time.Duration) (ok bool) {
x.b, ok = x.builder().objDuration(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddBase64Bytes(key string, val []byte, enc *base64.Encoding) (ok bool) {
x.b, ok = x.builder().objBase64Bytes(x.b, key, val, enc)
return
}
func (x *objectFields[E, P]) AddFloat64(key string, val float64) (ok bool) {
x.b, ok = x.builder().objFloat64(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddInt64(key string, val int64) (ok bool) {
x.b, ok = x.builder().objInt64(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddUint64(key string, val uint64) (ok bool) {
x.b, ok = x.builder().objUint64(x.b, key, val)
return
}
func (x *objectFields[E, P]) AddRawJSON(key string, val json.RawMessage) (ok bool) {
x.b, ok = x.builder().objRawJSON(x.b, key, val)
return
}
func (x *objectFields[E, P]) mustEmbedUnimplementedEvent() {}