소스 검색

Add response size to LogFormatterParams (#1752)

Pierre Massat 6 년 전
부모
커밋
184661cfa2
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      logger.go

+ 4 - 0
logger.go

@@ -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
 			}