Add response size to LogFormatterParams (#1752)

This commit is contained in:
Pierre Massat 2019-02-21 21:12:05 -08:00 committed by 田欧
parent d7daffc26b
commit 184661cfa2
1 changed files with 4 additions and 0 deletions

View File

@ -64,6 +64,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.
@ -191,6 +193,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
}