1 Star 0 Fork 0

天雨流芳 / go-micro-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
array_encoder.go 3.26 KB
一键复制 编辑 原始数据 按行查看 历史
天雨流芳 提交于 2024-03-14 19:42 . 日志模块
package logger
import (
"fmt"
"go.uber.org/zap/zapcore"
"time"
)
// 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))
}
1
https://gitee.com/tylf2018/go-micro-framework.git
git@gitee.com:tylf2018/go-micro-framework.git
tylf2018
go-micro-framework
go-micro-framework
e87e0c3d7074

搜索帮助

53164aa7 5694891 3bd8fe86 5694891