From 2958fb91c49456e4c21f145175b03e376a3c3d1b Mon Sep 17 00:00:00 2001 From: Liran BG Date: Mon, 17 Jan 2022 11:17:19 +0200 Subject: [PATCH] Use faster encoder (#8) --- go.mod | 1 + go.sum | 2 ++ logger.go | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/go.mod b/go.mod index 279269c..502b09c 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/nuclio/zap go 1.17 require ( + github.com/goccy/go-json v0.9.3 github.com/liranbg/uberzap v1.20.0-nuclio.1 github.com/logrusorgru/aurora/v3 v3.0.0 github.com/nuclio/errors v0.0.3 diff --git a/go.sum b/go.sum index dc514bf..5e097aa 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/goccy/go-json v0.9.3 h1:VYKeLtdIQXWaeTZy5JNGZbVui5ck7Vf5MlWEcflqz0s= +github.com/goccy/go-json v0.9.3/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= diff --git a/logger.go b/logger.go index 9b656ed..98cac29 100644 --- a/logger.go +++ b/logger.go @@ -24,6 +24,7 @@ import ( "strings" "time" + gojson "github.com/goccy/go-json" "github.com/liranbg/uberzap" "github.com/liranbg/uberzap/zapcore" "github.com/logrusorgru/aurora/v3" @@ -419,6 +420,9 @@ func (nz *NuclioZap) getEncoderConfig(encoding string, encoderConfig *EncoderCon EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: func(zapcore.EntryCaller, zapcore.PrimitiveArrayEncoder) {}, EncodeName: zapcore.FullNameEncoder, + NewReflectedEncoder: func(writer io.Writer) zapcore.ReflectedEncoder { + return gojson.NewEncoder(writer) + }, } }