Add response size to LogFormatterParams

This commit is contained in:
Pierre Massat 2019-01-27 10:02:02 -08:00
parent d27685e714
commit 45bf02c00e

View File

@ -63,6 +63,8 @@ type LogFormatterParams struct {
ErrorMessage string ErrorMessage string
// IsTerm shows whether does gin's output descriptor refers to a terminal. // IsTerm shows whether does gin's output descriptor refers to a terminal.
IsTerm bool IsTerm bool
// BodySize is the size of the Response Body
BodySize int
} }
// defaultLogFormatter is the default log format function Logger middleware uses. // 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.StatusCode = c.Writer.Status()
param.ErrorMessage = c.Errors.ByType(ErrorTypePrivate).String() param.ErrorMessage = c.Errors.ByType(ErrorTypePrivate).String()
param.BodySize = c.Writer.Size()
if raw != "" { if raw != "" {
path = path + "?" + raw path = path + "?" + raw
} }