0991555c2d
- 将日志记录库从 Logrus 替换为 Zerolog,提升性能和灵活性 - 更新各个模块的日志记录方式,确保一致性 - 优化错误处理逻辑,确保在发生错误时能够正确记录并传递错误信息 - 移除不再使用的错误处理字段,简化代码结构 - 更新相关文档以反映新的日志记录和错误处理机制
20 lines
671 B
Go
20 lines
671 B
Go
package json
|
|
|
|
// JSONMarshalFunc is used to marshal interface to JSON encoded byte slice.
|
|
// Making it package level instead of embedded in Encoder brings
|
|
// some extra efforts at importing, but avoids value copy when the functions
|
|
// of Encoder being invoked.
|
|
// DO REMEMBER to set this variable at importing, or
|
|
// you might get a nil pointer dereference panic at runtime.
|
|
var JSONMarshalFunc func(v interface{}) ([]byte, error)
|
|
|
|
type Encoder struct{}
|
|
|
|
// AppendKey appends a new key to the output JSON.
|
|
func (e Encoder) AppendKey(dst []byte, key string) []byte {
|
|
if dst[len(dst)-1] != '{' {
|
|
dst = append(dst, ',')
|
|
}
|
|
return append(e.AppendString(dst, key), ':')
|
|
}
|