feat(logger): show query string in logger. (#999) close #988

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-07-10 03:41:20 -05:00
committed by Javier Provecho Fernandez
parent fb7448f081
commit e31cbdf241
2 changed files with 7 additions and 1 deletions

View File

@ -77,6 +77,7 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
// Start timer
start := time.Now()
path := c.Request.URL.Path
raw := c.Request.URL.RawQuery
// Process request
c.Next()
@ -97,6 +98,10 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
}
comment := c.Errors.ByType(ErrorTypePrivate).String()
if raw != "" {
path = path + "?" + raw
}
fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %s %-7s %s\n%s",
end.Format("2006/01/02 - 15:04:05"),
statusColor, statusCode, reset,