0991555c2d
- 将日志记录库从 Logrus 替换为 Zerolog,提升性能和灵活性 - 更新各个模块的日志记录方式,确保一致性 - 优化错误处理逻辑,确保在发生错误时能够正确记录并传递错误信息 - 移除不再使用的错误处理字段,简化代码结构 - 更新相关文档以反映新的日志记录和错误处理机制
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
// +build binary_log
|
|
|
|
package zerolog
|
|
|
|
// This file contains bindings to do binary encoding.
|
|
|
|
import (
|
|
"github.com/rs/zerolog/internal/cbor"
|
|
)
|
|
|
|
var (
|
|
_ encoder = (*cbor.Encoder)(nil)
|
|
|
|
enc = cbor.Encoder{}
|
|
)
|
|
|
|
func init() {
|
|
// using closure to reflect the changes at runtime.
|
|
cbor.JSONMarshalFunc = func(v interface{}) ([]byte, error) {
|
|
return InterfaceMarshalFunc(v)
|
|
}
|
|
}
|
|
|
|
func appendJSON(dst []byte, j []byte) []byte {
|
|
return cbor.AppendEmbeddedJSON(dst, j)
|
|
}
|
|
func appendCBOR(dst []byte, c []byte) []byte {
|
|
return cbor.AppendEmbeddedCBOR(dst, c)
|
|
}
|
|
|
|
// decodeIfBinaryToString - converts a binary formatted log msg to a
|
|
// JSON formatted String Log message.
|
|
func decodeIfBinaryToString(in []byte) string {
|
|
return cbor.DecodeIfBinaryToString(in)
|
|
}
|
|
|
|
func decodeObjectToStr(in []byte) string {
|
|
return cbor.DecodeObjectToStr(in)
|
|
}
|
|
|
|
// decodeIfBinaryToBytes - converts a binary formatted log msg to a
|
|
// JSON formatted Bytes Log message.
|
|
func decodeIfBinaryToBytes(in []byte) []byte {
|
|
return cbor.DecodeIfBinaryToBytes(in)
|
|
}
|