-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharrayencoder.go
116 lines (89 loc) · 3.26 KB
/
arrayencoder.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package otelzap
import (
"fmt"
"time"
"go.uber.org/zap/zapcore"
)
// bufferArrayEncoder implements zapcore.bufferArrayEncoder.
// It represents all added objects to their string values and
// adds them to the stringsSlice buffer.
type bufferArrayEncoder struct {
stringsSlice []string
}
var _ zapcore.ArrayEncoder = (*bufferArrayEncoder)(nil)
func (t *bufferArrayEncoder) AppendComplex128(v complex128) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendComplex64(v complex64) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendArray(v zapcore.ArrayMarshaler) error {
enc := &bufferArrayEncoder{}
err := v.MarshalLogArray(enc)
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", enc.stringsSlice))
return err
}
func (t *bufferArrayEncoder) AppendObject(v zapcore.ObjectMarshaler) error {
m := zapcore.NewMapObjectEncoder()
err := v.MarshalLogObject(m)
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", m.Fields))
return err
}
func (t *bufferArrayEncoder) AppendReflected(v interface{}) error {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
return nil
}
func (t *bufferArrayEncoder) AppendBool(v bool) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendByteString(v []byte) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendDuration(v time.Duration) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendFloat64(v float64) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendFloat32(v float32) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendInt(v int) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendInt64(v int64) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendInt32(v int32) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendInt16(v int16) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendInt8(v int8) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendString(v string) {
t.stringsSlice = append(t.stringsSlice, v)
}
func (t *bufferArrayEncoder) AppendTime(v time.Time) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendUint(v uint) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendUint64(v uint64) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendUint32(v uint32) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendUint16(v uint16) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendUint8(v uint8) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}
func (t *bufferArrayEncoder) AppendUintptr(v uintptr) {
t.stringsSlice = append(t.stringsSlice, fmt.Sprintf("%v", v))
}