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
|
var entry *zerolog.Event
|
||||||
interrupt := recover()
|
interrupt := recover()
|
||||||
if interrupt != nil {
|
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.Header("requestid", id.String())
|
||||||
c.AbortWithStatus(http.StatusInternalServerError)
|
c.AbortWithStatus(http.StatusInternalServerError)
|
||||||
entry = log.Error().Err(err).Int("statuscode", 500)
|
|
||||||
entry.Stack()
|
entry.Stack()
|
||||||
} else {
|
} else {
|
||||||
statuscode := c.Writer.Status()
|
statuscode := c.Writer.Status()
|
||||||
|
|
Laden…
In neuem Issue referenzieren