Normal log and error log are printed in the same call.

This commit is contained in:
Manu Mtz-Almeida 2014-07-13 00:18:33 +02:00
parent e2242b59e6
commit f63a354b40
2 changed files with 5 additions and 6 deletions

3
gin.go
View File

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

View File

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