From 83b5730a186f0c53360673f3c3563993757863bf Mon Sep 17 00:00:00 2001 From: Jules Michael Date: Thu, 31 Mar 2022 13:52:41 +0400 Subject: [PATCH] feat(http/server): use logger as default debug writer --- http/server.go | 2 ++ logger/logger.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/http/server.go b/http/server.go index 9b12227..d21f3da 100644 --- a/http/server.go +++ b/http/server.go @@ -56,6 +56,8 @@ func NewServer( gin.SetMode(gin.ReleaseMode) } + gin.DefaultWriter = logger + s := Server{ router: gin.Default(), addr: fmt.Sprintf("%s:%d", cfg.HttpServerHost, cfg.HttpServerPort), diff --git a/logger/logger.go b/logger/logger.go index e472823..f5c4960 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -46,3 +46,9 @@ 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 +}