diff --git a/middleware/middleware.go b/middleware/middleware.go index cdd75be..38cef43 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -23,10 +23,14 @@ func LogMiddleware(c *gin.Context) { var entry *zerolog.Event interrupt := recover() if interrupt != nil { - err := interrupt.(error) + entry = log.Error().Int("statuscode", 500) + if err, ok := interrupt.(error); ok { + entry.Err(err).Stack() + } else { + entry.Interface("recover", interrupt) + } c.Header("requestid", id.String()) c.AbortWithStatus(http.StatusInternalServerError) - entry = log.Error().Err(err).Int("statuscode", 500) entry.Stack() } else { statuscode := c.Writer.Status()