From c75f265574f8124178429169de891f38eabf6c24 Mon Sep 17 00:00:00 2001 From: Jules Michael Date: Thu, 31 Mar 2022 14:59:36 +0400 Subject: [PATCH] refactor(http/server): better io.Writer from logger --- http/server.go | 7 +++++-- logger/logger.go | 6 ------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/http/server.go b/http/server.go index a206951..cf673d4 100644 --- a/http/server.go +++ b/http/server.go @@ -16,6 +16,7 @@ import ( "github.com/gin-gonic/gin" "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin" "go.uber.org/fx" + "go.uber.org/zap" ) const ( @@ -56,8 +57,10 @@ func NewServer( gin.SetMode(gin.ReleaseMode) } - gin.DefaultWriter = logger - gin.DefaultErrorWriter = logger + writer := zap.NewStdLog(logger.Desugar().Logger).Writer() + + gin.DefaultWriter = writer + gin.DefaultErrorWriter = writer s := Server{ router: gin.Default(), diff --git a/logger/logger.go b/logger/logger.go index f5c4960..e472823 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -46,9 +46,3 @@ func New(lc fx.Lifecycle, cfg *config.Config) (*Logger, error) { return &Logger{otellogger.Sugar()}, nil } - -func (l *Logger) Write(p []byte) (n int, err error) { - l.Debug(string(p)) - - return len(p), nil -}