Skip to content

Commit

Permalink
not display color when set disableColor (gin-gonic#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkerou authored and Tony Yip committed Feb 20, 2018
1 parent 263b132 commit 815dd56
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
clientIP := c.ClientIP()
method := c.Request.Method
statusCode := c.Writer.Status()
var statusColor, methodColor string
var statusColor, methodColor, resetColor string
if isTerm {
statusColor = colorForStatus(statusCode)
methodColor = colorForMethod(method)
resetColor = reset
}
comment := c.Errors.ByType(ErrorTypePrivate).String()

Expand All @@ -104,10 +105,10 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {

fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
end.Format("2006/01/02 - 15:04:05"),
statusColor, statusCode, reset,
statusColor, statusCode, resetColor,
latency,
clientIP,
methodColor, method, reset,
methodColor, method, resetColor,
path,
comment,
)
Expand Down

0 comments on commit 815dd56

Please sign in to comment.