optimized the inerrupt handling
Dieser Commit ist enthalten in:
Ursprung
4aa50328f2
Commit
818560df17
|
@ -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()
|
||||
|
|
Laden…
In neuem Issue referenzieren