From 8625864d43d52339ad81f9d6b0a3057c8915a916 Mon Sep 17 00:00:00 2001 From: Xingchen Wang Date: Sat, 21 Dec 2024 11:22:54 +0800 Subject: [PATCH] bugfix:`SetSlowThreshold` not effective in function `logDetails` (#4511) Co-authored-by: Star Wang --- rest/handler/loghandler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/handler/loghandler.go b/rest/handler/loghandler.go index eaf59a16..30348e3b 100644 --- a/rest/handler/loghandler.go +++ b/rest/handler/loghandler.go @@ -158,7 +158,7 @@ func logDetails(r *http.Request, response *detailLoggedResponseWriter, timer *ut logger := logx.WithContext(r.Context()) buf.WriteString(fmt.Sprintf("[HTTP] %s - %d - %s - %s\n=> %s\n", r.Method, code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r))) - if duration > defaultSlowThreshold { + if duration > slowThreshold.Load() { logger.Slowf("[HTTP] %s - %d - %s - slowcall(%s)\n=> %s\n", r.Method, code, r.RemoteAddr, fmt.Sprintf("slowcall(%s)", timex.ReprOfDuration(duration)), dumpRequest(r)) }