From 8eb474c0ab12dbc176c0ac57860ffec8cac87600 Mon Sep 17 00:00:00 2001 From: mstmdev Date: Fri, 7 Jan 2022 00:22:28 +0800 Subject: [PATCH] Use the out.Write to write the log content immediately, because the LogFormatter returns a string, the fmt.Fprint is unnecessary here --- logger.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logger.go b/logger.go index 61b84546..2954709a 100644 --- a/logger.go +++ b/logger.go @@ -6,6 +6,7 @@ package gin import ( "fmt" + "github.com/gin-gonic/gin/internal/bytesconv" "io" "net/http" "os" @@ -264,7 +265,7 @@ func LoggerWithConfig(conf LoggerConfig) HandlerFunc { param.Path = path - fmt.Fprint(out, formatter(param)) + out.Write(bytesconv.StringToBytes(formatter(param))) } } }