khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame^] | 1 | // +build binary_log |
| 2 | |
| 3 | package zerolog |
| 4 | |
| 5 | // This file contains bindings to do binary encoding. |
| 6 | |
| 7 | import ( |
| 8 | "github.com/rs/zerolog/internal/cbor" |
| 9 | ) |
| 10 | |
| 11 | var ( |
| 12 | _ encoder = (*cbor.Encoder)(nil) |
| 13 | |
| 14 | enc = cbor.Encoder{} |
| 15 | ) |
| 16 | |
| 17 | func appendJSON(dst []byte, j []byte) []byte { |
| 18 | return cbor.AppendEmbeddedJSON(dst, j) |
| 19 | } |
| 20 | |
| 21 | // decodeIfBinaryToString - converts a binary formatted log msg to a |
| 22 | // JSON formatted String Log message. |
| 23 | func decodeIfBinaryToString(in []byte) string { |
| 24 | return cbor.DecodeIfBinaryToString(in) |
| 25 | } |
| 26 | |
| 27 | func decodeObjectToStr(in []byte) string { |
| 28 | return cbor.DecodeObjectToStr(in) |
| 29 | } |
| 30 | |
| 31 | // decodeIfBinaryToBytes - converts a binary formatted log msg to a |
| 32 | // JSON formatted Bytes Log message. |
| 33 | func decodeIfBinaryToBytes(in []byte) []byte { |
| 34 | return cbor.DecodeIfBinaryToBytes(in) |
| 35 | } |