From 45bf02c00ef04cd764194ece1f2bddef88902aa9 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Sun, 27 Jan 2019 10:02:02 -0800 Subject: [PATCH] Add response size to LogFormatterParams --- logger.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/logger.go b/logger.go index d2869f514a..cff8981ccc 100644 --- a/logger.go +++ b/logger.go @@ -63,6 +63,8 @@ type LogFormatterParams struct { ErrorMessage string // IsTerm shows whether does gin's output descriptor refers to a terminal. IsTerm bool + // BodySize is the size of the Response Body + BodySize int } // defaultLogFormatter is the default log format function Logger middleware uses. @@ -185,6 +187,8 @@ func LoggerWithConfig(conf LoggerConfig) HandlerFunc { param.StatusCode = c.Writer.Status() param.ErrorMessage = c.Errors.ByType(ErrorTypePrivate).String() + param.BodySize = c.Writer.Size() + if raw != "" { path = path + "?" + raw }