Skip to content

Commit

Permalink
Normal log and error log are printed in the same call.
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jul 12, 2014
1 parent e2242b5 commit f63a354
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 3 additions & 0 deletions gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func (a errorMsgs) ByType(typ uint32) errorMsgs {
}

func (a errorMsgs) String() string {
if len(a) == 0 {
return ""
}
var buffer bytes.Buffer
for i, msg := range a {
text := fmt.Sprintf("Error #%02d: %s \n Meta: %v\n", (i + 1), msg.Err, msg.Meta)
Expand Down
8 changes: 2 additions & 6 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,13 @@ func Logger() HandlerFunc {
}
end := time.Now()
latency := end.Sub(start)
stdlogger.Printf("[GIN] %v |%s %3d %s| %12v | %s %4s %s\n",
stdlogger.Printf("[GIN] %v |%s %3d %s| %12v | %s %4s %s\n%s",
end.Format("2006/01/02 - 15:04:05"),
color, code, reset,
latency,
requester,
c.Request.Method, c.Request.URL.Path,
c.Errors.String(),
)

// Calculate resolution time
if len(c.Errors) > 0 {
stdlogger.Println(c.Errors.String())
}
}
}

0 comments on commit f63a354

Please sign in to comment.