diff --git a/recovery.go b/recovery.go index 89b39fe..dcbeba7 100644 --- a/recovery.go +++ b/recovery.go @@ -12,6 +12,7 @@ import ( "log" "net/http/httputil" "runtime" + "time" ) var ( @@ -38,7 +39,7 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc { if logger != nil { stack := stack(3) httprequest, _ := httputil.DumpRequest(c.Request, false) - logger.Printf("[Recovery] panic recovered:\n%s\n%s\n%s%s", string(httprequest), err, stack, reset) + logger.Printf("[Recovery] %s panic recovered:\n%s\n%s\n%s%s", timeFormat(time.Now()), string(httprequest), err, stack, reset) } c.AbortWithStatus(500) } @@ -107,3 +108,8 @@ func function(pc uintptr) []byte { name = bytes.Replace(name, centerDot, dot, -1) return name } + +func timeFormat(t time.Time) string { + var timeString = t.Format("2006/01/02 - 15:04:05") + return timeString +}