Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Bo-Yi Wu · committed by Javier Provecho Fernandez · parent fb7448f · Browse files · 2 files+7 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

Diff stats

2 files+7 added−1 removed

  • other:+7 added−1 removed

2 files+7 added−1 removed

modified:logger_test.go+2 added-1 removed
26 unmodified lines
27 router.PATCH("/example", func(c *Context) {})28 router.HEAD("/example", func(c *Context) {})29 router.OPTIONS("/example", func(c *Context) {})3031 performRequest(router, "GET", "/example")31 performRequest(router, "GET", "/example?a=100")32 assert.Contains(t, buffer.String(), "200")33 assert.Contains(t, buffer.String(), "GET")34 assert.Contains(t, buffer.String(), "/example")35 assert.Contains(t, buffer.String(), "a=100")3637 // I wrote these first (extending the above) but then realized they are more38 // like integration tests because they test the whole logging process rather39 // than individual functions. Im not sure where these should go.
110 unmodified lines
modified:logger.go+5 added
75 unmodified lines
76 return func(c *Context) {77 // Start timer78 start := time.Now()79 path := c.Request.URL.Path80 raw := c.Request.URL.RawQuery8182 // Process request83 c.Next()84
12 unmodified lines
97 methodColor = colorForMethod(method)98 }99 comment := c.Errors.ByType(ErrorTypePrivate).String()100101 if raw != "" {102 path = path + "?" + raw103 }104105 fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %s %-7s %s\n%s",106 end.Format("2006/01/02 - 15:04:05"),107 statusColor, statusCode, reset,108 latency,
42 unmodified lines