Internal

internal/json

github.com/rs/zerolog/internal/json

import "github.com/rs/zerolog/internal/json"

Variables

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.

Source: internal/json/base.go:9

var JSONMarshalFunc func(v interface{}) ([]byte, error)

Types

type Encoder

Source: internal/json/base.go:11

type Encoder struct{}

func (Encoder) AppendArrayDelim(dst []byte) []byte

Source: internal/json/types.go:42

AppendArrayDelim adds markers to indicate end of a particular array element.

func (Encoder) AppendArrayEnd(dst []byte) []byte

Source: internal/json/types.go:37

AppendArrayEnd adds markers to indicate the end of an array.

func (Encoder) AppendArrayStart(dst []byte) []byte

Source: internal/json/types.go:32

AppendArrayStart adds markers to indicate the start of an array.

func (Encoder) AppendBeginMarker(dst []byte) []byte

Source: internal/json/types.go:17

AppendBeginMarker inserts a map start into the dst byte array.

func (Encoder) AppendBool(dst []byte, val bool) []byte

Source: internal/json/types.go:51

AppendBool converts the input bool to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendBools(dst []byte, vals []bool) []byte

Source: internal/json/types.go:57

AppendBools encodes the input bools to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendBytes(dst, s []byte) []byte

Source: internal/json/bytes.go:6

AppendBytes is a mirror of appendString with []byte arg

func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, format string, useInt bool, precision int) []byte

Source: internal/json/time.go:94

AppendDuration formats the input duration with the given unit & format and appends the encoded string to the input byte slice.

func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, format string, useInt bool, precision int) []byte

Source: internal/json/time.go:111

AppendDurations formats the input durations with the given unit & format and appends the encoded string list to the input byte slice.

func (Encoder) AppendEndMarker(dst []byte) []byte

Source: internal/json/types.go:22

AppendEndMarker inserts a map end into the dst byte array.

func (Encoder) AppendFloat32(dst []byte, val float32, precision int) []byte

Source: internal/json/types.go:340

AppendFloat32 converts the input float32 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendFloat64(dst []byte, val float64, precision int) []byte

Source: internal/json/types.go:363

AppendFloat64 converts the input float64 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendFloats32(dst []byte, vals []float32, precision int) []byte

Source: internal/json/types.go:346

AppendFloats32 encodes the input float32s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendFloats64(dst []byte, vals []float64, precision int) []byte

Source: internal/json/types.go:369

AppendFloats64 encodes the input float64s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendHex(dst, s []byte) []byte

Source: internal/json/bytes.go:23

AppendHex encodes the input bytes to a hex string and appends the encoded string to the input byte slice.

The operation loops though each byte and encodes it as hex using the hex lookup table.

func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte

Source: internal/json/types.go:422

AppendIPAddr adds a net.IP IPv4 or IPv6 address to dst.

func (e Encoder) AppendIPAddrs(dst []byte, ips []net.IP) []byte

Source: internal/json/types.go:427

AppendIPAddrs adds a []net.IP array of IPv4 or IPv6 address to dst.

func (e Encoder) AppendIPPrefix(dst []byte, pfx net.IPNet) []byte

Source: internal/json/types.go:443

AppendIPPrefix adds a net.IPNet IPv4 or IPv6 Prefix (address & mask) to dst.

func (e Encoder) AppendIPPrefixes(dst []byte, pfxs []net.IPNet) []byte

Source: internal/json/types.go:448

AppendIPPrefixes adds a []net.IPNet array of IPv4 or IPv6 Prefix (address & mask) to dst.

func (Encoder) AppendInt(dst []byte, val int) []byte

Source: internal/json/types.go:74

AppendInt converts the input int to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendInt16(dst []byte, val int16) []byte

Source: internal/json/types.go:120

AppendInt16 converts the input int16 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendInt32(dst []byte, val int32) []byte

Source: internal/json/types.go:143

AppendInt32 converts the input int32 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendInt64(dst []byte, val int64) []byte

Source: internal/json/types.go:166

AppendInt64 converts the input int64 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendInt8(dst []byte, val int8) []byte

Source: internal/json/types.go:97

AppendInt8 converts the input []int8 to a string and appends the encoded string to the input byte slice.

func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte

Source: internal/json/types.go:386

AppendInterface marshals the input interface to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendInts(dst []byte, vals []int) []byte

Source: internal/json/types.go:80

AppendInts encodes the input ints to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendInts16(dst []byte, vals []int16) []byte

Source: internal/json/types.go:126

AppendInts16 encodes the input int16s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendInts32(dst []byte, vals []int32) []byte

Source: internal/json/types.go:149

AppendInts32 encodes the input int32s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendInts64(dst []byte, vals []int64) []byte

Source: internal/json/types.go:172

AppendInts64 encodes the input int64s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendInts8(dst []byte, vals []int8) []byte

Source: internal/json/types.go:103

AppendInts8 encodes the input int8s to json and appends the encoded string list to the input byte slice.

func (e Encoder) AppendKey(dst []byte, key string) []byte

Source: internal/json/base.go:14

AppendKey appends a new key to the output JSON.

func (Encoder) AppendLineBreak(dst []byte) []byte

Source: internal/json/types.go:27

AppendLineBreak appends a line break.

func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte

Source: internal/json/types.go:464

AppendMACAddr adds a net.HardwareAddr MAC address to dst.

func (Encoder) AppendNil(dst []byte) []byte

Source: internal/json/types.go:12

AppendNil inserts a 'Nil' object into the dst byte array.

func (Encoder) AppendObjectData(dst []byte, o []byte) []byte

Source: internal/json/types.go:404

AppendObjectData takes in an object that is already in a byte array and adds it to the dst.

func (Encoder) AppendString(dst []byte, s string) []byte

Source: internal/json/string.go:44

AppendString encodes the input string to json and appends the encoded string to the input byte slice.

The operation loops though each byte in the string looking for characters that need json or utf8 encoding. If the string does not need encoding, then the string is appended in its entirety to the byte slice. If we encounter a byte that does need encoding, switch up the operation and perform a byte-by-byte read-encode-append.

func (e Encoder) AppendStringer(dst []byte, val fmt.Stringer) []byte

Source: internal/json/string.go:84

AppendStringer encodes the input Stringer to json and appends the encoded Stringer value to the input byte slice.

func (e Encoder) AppendStringers(dst []byte, vals []fmt.Stringer) []byte

Source: internal/json/string.go:68

AppendStringers encodes the provided Stringer list to json and appends the encoded Stringer list to the input byte slice.

func (e Encoder) AppendStrings(dst []byte, vals []string) []byte

Source: internal/json/string.go:20

AppendStrings encodes the input strings to json and appends the encoded string list to the input byte slice.

func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte

Source: internal/json/time.go:21

AppendTime formats the input time with the given format and appends the encoded string to the input byte slice.

func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte

Source: internal/json/time.go:37

AppendTimes converts the input times with the given format and appends the encoded string list to the input byte slice.

func (e Encoder) AppendType(dst []byte, i interface{}) []byte

Source: internal/json/types.go:395

AppendType appends the parameter type (as a string) to the input byte slice.

func (Encoder) AppendUint(dst []byte, val uint) []byte

Source: internal/json/types.go:189

AppendUint converts the input uint to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendUint16(dst []byte, val uint16) []byte

Source: internal/json/types.go:235

AppendUint16 converts the input uint16 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendUint32(dst []byte, val uint32) []byte

Source: internal/json/types.go:258

AppendUint32 converts the input uint32 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendUint64(dst []byte, val uint64) []byte

Source: internal/json/types.go:281

AppendUint64 converts the input uint64 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendUint8(dst []byte, val uint8) []byte

Source: internal/json/types.go:212

AppendUint8 converts the input uint8 to a string and appends the encoded string to the input byte slice.

func (Encoder) AppendUints(dst []byte, vals []uint) []byte

Source: internal/json/types.go:195

AppendUints encodes the input uints to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendUints16(dst []byte, vals []uint16) []byte

Source: internal/json/types.go:241

AppendUints16 encodes the input uint16s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendUints32(dst []byte, vals []uint32) []byte

Source: internal/json/types.go:264

AppendUints32 encodes the input uint32s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendUints64(dst []byte, vals []uint64) []byte

Source: internal/json/types.go:287

AppendUints64 encodes the input uint64s to json and appends the encoded string list to the input byte slice.

func (Encoder) AppendUints8(dst []byte, vals []uint8) []byte

Source: internal/json/types.go:218

AppendUints8 encodes the input uint8s to json and appends the encoded string list to the input byte slice.

Edit this page

Sourcey-generated documentation mirror for rs/zerolog (MIT), built from source at a pinned commit.Docs by Sourcey