package zapjournal
import (
)
type jsonEncoder struct {
bufp *[]byte
jsonState
}
type jsonState struct {
depth int
prev bool
}
func ( *jsonEncoder) () []byte {
return *.bufp
}
func ( *jsonEncoder) ( []byte) {
*.bufp =
}
func ( *jsonEncoder) () jsonState {
:= .jsonState
.jsonState = jsonState{}
return
}
func ( *jsonEncoder) ( string) {
.appendSep()
.appendQuotedString()
.appendColon()
}
func ( *jsonEncoder) ( string) {
.setBuf(strconv.AppendQuote(.buf(), ))
}
func ( *jsonEncoder) ( int64) {
.appendQuote()
.setBuf(strconv.AppendInt(.buf(), , 10))
.appendQuote()
}
func ( *jsonEncoder) ( uint64) {
.appendQuote()
.setBuf(strconv.AppendUint(.buf(), , 10))
.appendQuote()
}
func ( *jsonEncoder) ( uintptr) {
.appendQuote()
.setBuf(append(.buf(), "0x"...))
.setBuf(strconv.AppendUint(.buf(), uint64(), 16))
.appendQuote()
}
func ( *jsonEncoder) ( float64, int) {
.appendQuote()
.setBuf(strconv.AppendFloat(.buf(), , 'g', -1, ))
.appendQuote()
}
func ( *jsonEncoder) ( complex128, int) {
.appendQuote()
.setBuf(strconvAppendComplex(.buf(), , 'g', -1, ))
.appendQuote()
}
func ( *jsonEncoder) ( any) error {
:= bytes.NewBuffer(.buf())
:= json.NewEncoder()
.SetEscapeHTML(false)
:= .Encode()
.setBuf(.Bytes())
return
}
func ( *jsonEncoder) ( byte) {
.setBuf(append(.buf(), ))
}
func ( *jsonEncoder) () {
.appendByte(':')
}
func ( *jsonEncoder) () {
.appendByte('"')
}
func ( *jsonEncoder) () {
.appendByte('[')
}
func ( *jsonEncoder) () {
.appendByte(']')
}
func ( *jsonEncoder) () {
.appendByte('{')
}
func ( *jsonEncoder) () {
.appendByte('}')
}
func ( *jsonEncoder) () {
if !.prev {
.prev = true
return
}
.setBuf(append(.buf(), ','))
}
func ( *jsonEncoder) () {
for ; .depth > 0; .depth-- {
.appendCloseObject()
}
.prev = false
}
func ( *jsonEncoder) ( string, []byte) {
.appendSep()
.encodeBinary()
}
func ( *jsonEncoder) ( []byte) {
.setBuf(base64Append(base64.StdEncoding, .buf(), ))
}
func ( *jsonEncoder) ( string, time.Duration) {
.appendKey()
.encodeDuration()
}
func ( *jsonEncoder) ( time.Duration) {
.appendSep()
.encodeDuration()
}
func ( *jsonEncoder) ( time.Duration) {
.appendQuote()
.setBuf(append(.buf(), .String()...))
.appendQuote()
}
func ( *jsonEncoder) ( string, time.Time) {
.appendKey()
.encodeTime()
}
func ( *jsonEncoder) ( time.Time) {
.appendSep()
.encodeTime()
}
func ( *jsonEncoder) ( time.Time) {
.appendQuote()
.setBuf(.AppendFormat(.buf(), time.RFC3339Nano))
.appendQuote()
}
func ( *jsonEncoder) ( string, bool) {
.appendKey()
.encodeBool()
}
func ( *jsonEncoder) ( bool) {
.appendSep()
.encodeBool()
}
func ( *jsonEncoder) ( bool) {
.setBuf(strconv.AppendBool(.buf(), ))
}
func ( *jsonEncoder) ( string, []byte) {
.appendKey()
.encodeByteString()
}
func ( *jsonEncoder) ( []byte) {
.appendSep()
.encodeByteString()
}
func ( *jsonEncoder) ( []byte) {
.appendQuotedString(string())
}
func ( *jsonEncoder) (, string) {
.appendKey()
.encodeString()
}
func ( *jsonEncoder) ( string) {
.appendSep()
.encodeString()
}
func ( *jsonEncoder) ( string) {
.appendQuotedString()
}
func ( *jsonEncoder) ( string, complex128) {
.appendKey()
.encodeComplex128()
}
func ( *jsonEncoder) ( complex128) {
.appendSep()
.encodeComplex128()
}
func ( *jsonEncoder) ( complex128) {
.appendComplex(, 128)
}
func ( *jsonEncoder) ( string, complex64) {
.appendKey()
.encodeComplex64()
}
func ( *jsonEncoder) ( complex64) {
.appendSep()
.encodeComplex64()
}
func ( *jsonEncoder) ( complex64) {
.appendComplex(complex128(), 64)
}
func ( *jsonEncoder) ( string, float64) {
.appendKey()
.encodeFloat64()
}
func ( *jsonEncoder) ( float64) {
.appendSep()
.encodeFloat64()
}
func ( *jsonEncoder) ( float64) {
.appendFloat(, 64)
}
func ( *jsonEncoder) ( string, float32) {
.appendKey()
.encodeFloat32()
}
func ( *jsonEncoder) ( float32) {
.appendSep()
.encodeFloat32()
}
func ( *jsonEncoder) ( float32) {
.appendFloat(float64(), 32)
}
func ( *jsonEncoder) ( string, int) {
.appendKey()
.encodeInt()
}
func ( *jsonEncoder) ( int) {
.appendSep()
.encodeInt()
}
func ( *jsonEncoder) ( int) {
.appendInt(int64())
}
func ( *jsonEncoder) ( string, int64) {
.appendKey()
.encodeInt64()
}
func ( *jsonEncoder) ( int64) {
.appendSep()
.encodeInt64()
}
func ( *jsonEncoder) ( int64) {
.appendInt()
}
func ( *jsonEncoder) ( string, int32) {
.appendKey()
.encodeInt32()
}
func ( *jsonEncoder) ( int32) {
.appendSep()
.encodeInt32()
}
func ( *jsonEncoder) ( int32) {
.appendInt(int64())
}
func ( *jsonEncoder) ( string, int16) {
.appendKey()
.encodeInt16()
}
func ( *jsonEncoder) ( int16) {
.appendSep()
.encodeInt16()
}
func ( *jsonEncoder) ( int16) {
.appendInt(int64())
}
func ( *jsonEncoder) ( string, int8) {
.appendKey()
.encodeInt8()
}
func ( *jsonEncoder) ( int8) {
.appendSep()
.encodeInt8()
}
func ( *jsonEncoder) ( int8) {
.appendInt(int64())
}
func ( *jsonEncoder) ( string, uint) {
.appendKey()
.encodeUint()
}
func ( *jsonEncoder) ( uint) {
.appendSep()
.encodeUint()
}
func ( *jsonEncoder) ( uint) {
.appendUint(uint64())
}
func ( *jsonEncoder) ( string, uint64) {
.appendKey()
.encodeUint64()
}
func ( *jsonEncoder) ( uint64) {
.appendSep()
.encodeUint64()
}
func ( *jsonEncoder) ( uint64) {
.appendUint()
}
func ( *jsonEncoder) ( string, uint32) {
.appendKey()
.encodeUint32()
}
func ( *jsonEncoder) ( uint32) {
.appendSep()
.encodeUint32()
}
func ( *jsonEncoder) ( uint32) {
.appendUint(uint64())
}
func ( *jsonEncoder) ( string, uint16) {
.appendKey()
.encodeUint16()
}
func ( *jsonEncoder) ( uint16) {
.appendSep()
.encodeUint16()
}
func ( *jsonEncoder) ( uint16) {
.appendUint(uint64())
}
func ( *jsonEncoder) ( string, uint8) {
.appendKey()
.encodeUint8()
}
func ( *jsonEncoder) ( uint8) {
.appendSep()
.encodeUint8()
}
func ( *jsonEncoder) ( uint8) {
.appendUint(uint64())
}
func ( *jsonEncoder) ( string, uintptr) {
.appendKey()
.encodeUintptr()
}
func ( *jsonEncoder) ( uintptr) {
.appendSep()
.encodeUintptr()
}
func ( *jsonEncoder) ( uintptr) {
.appendUintptr()
}
func ( *jsonEncoder) ( string, any) error {
.appendKey()
return .encodeReflected()
}
func ( *jsonEncoder) ( any) error {
.appendSep()
return .encodeReflected()
}
func ( *jsonEncoder) ( any) error {
return .appendMarshalJSON()
}
func ( *jsonEncoder) ( string, zapcore.ArrayMarshaler) error {
.appendKey()
return .encodeArray()
}
func ( *jsonEncoder) ( zapcore.ArrayMarshaler) error {
.appendSep()
return .encodeArray()
}
func ( *jsonEncoder) ( zapcore.ArrayMarshaler) error {
.appendOpenArray()
:= .nested()
:= .MarshalLogArray()
.complete()
.jsonState =
.appendCloseArray()
return
}
func ( *jsonEncoder) ( string, zapcore.ObjectMarshaler) error {
.appendKey()
return .encodeObject()
}
func ( *jsonEncoder) ( zapcore.ObjectMarshaler) error {
.appendSep()
return .encodeObject()
}
func ( *jsonEncoder) ( zapcore.ObjectMarshaler) error {
.appendOpenObject()
:= .nested()
:= .MarshalLogObject()
.complete()
.jsonState =
.appendCloseObject()
return
}
func ( *jsonEncoder) ( string) {
.appendKey()
.appendOpenObject()
.prev = false
.depth++
}