summary refs log tree commit diff
path: root/vendor/github.com/rs/zerolog/encoder_cbor.go
diff options
context:
space:
mode:
authorEmile <git@emile.space>2024-10-25 15:55:50 +0200
committerEmile <git@emile.space>2024-10-25 15:55:50 +0200
commitc90f36e3dd179d2de96f4f5fe38d8dc9a9de6dfe (patch)
tree89e9afb41c5bf76f48cfb09305a2d3db8d302b06 /vendor/github.com/rs/zerolog/encoder_cbor.go
parent98bbb0f559a8883bc47bae80607dbe326a448e61 (diff)
vendor HEAD main
Diffstat (limited to 'vendor/github.com/rs/zerolog/encoder_cbor.go')
-rw-r--r--vendor/github.com/rs/zerolog/encoder_cbor.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/github.com/rs/zerolog/encoder_cbor.go b/vendor/github.com/rs/zerolog/encoder_cbor.go
new file mode 100644
index 0000000..36cb994
--- /dev/null
+++ b/vendor/github.com/rs/zerolog/encoder_cbor.go
@@ -0,0 +1,45 @@
+// +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)
+}