Skip to content

Commit

Permalink
Add response size to LogFormatterParams (#1752)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Massat authored and thinkerou committed Feb 22, 2019
1 parent d7daffc commit 184661c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 184661c

Please sign in to comment.