2018-04-30 18:42:17 +05:00
|
|
|
// +build binary_log
|
|
|
|
|
|
|
|
package zerolog
|
|
|
|
|
|
|
|
// This file contains bindings to do binary encoding.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/rs/zerolog/internal/cbor"
|
|
|
|
)
|
|
|
|
|
2019-03-07 07:56:50 +05:00
|
|
|
var (
|
|
|
|
_ encoder = (*cbor.Encoder)(nil)
|
2018-04-30 18:42:17 +05:00
|
|
|
|
2019-03-07 07:56:50 +05:00
|
|
|
enc = cbor.Encoder{}
|
|
|
|
)
|
2018-04-30 18:42:17 +05:00
|
|
|
|
|
|
|
func appendJSON(dst []byte, j []byte) []byte {
|
|
|
|
return cbor.AppendEmbeddedJSON(dst, j)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|