From edd86f2bb811ec877de1676c0b62de8e8a9f4728 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Tue, 21 May 2024 17:16:39 +0800 Subject: [PATCH] log fix --- library/middleware/logger.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/middleware/logger.go b/library/middleware/logger.go index 76ec9a1b..2d60fa22 100644 --- a/library/middleware/logger.go +++ b/library/middleware/logger.go @@ -90,7 +90,9 @@ func LoggerMiddleware(conf gin.LoggerConfig) gin.HandlerFunc { if ok { bodyStr = string(body.([]byte)) } - logger.Info("%s params: %s", formatter(param), bodyStr) + if _, ok := NoLogRoutesMap[param.Path]; !ok { + logger.Info("%s params: %s", formatter(param), bodyStr) + } //logger.Info("%s response: %s", formatter(param), blw.body.String()) //logger.WithCtx(c.Request.Context()).Info("%s params: %s", formatter(param), bodyStr) @@ -100,3 +102,7 @@ func LoggerMiddleware(conf gin.LoggerConfig) gin.HandlerFunc { } } } + +var NoLogRoutesMap = map[string]bool{ + "/healthcheck": true, +}