log http panic.

This commit is contained in:
Miroslav Šedivý 2021-09-17 19:37:09 +02:00
parent 7e548ec00a
commit 6026ab8a27

View File

@ -7,7 +7,6 @@ import (
"github.com/go-chi/chi/middleware" "github.com/go-chi/chi/middleware"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"demodesk/neko/internal/types" "demodesk/neko/internal/types"
"demodesk/neko/internal/utils" "demodesk/neko/internal/utils"
@ -114,10 +113,8 @@ func (e *logEntry) Write(status, bytes int, header http.Header, elapsed time.Dur
} }
func (e *logEntry) Panic(v interface{}, stack []byte) { func (e *logEntry) Panic(v interface{}, stack []byte) {
message := fmt.Sprintf("%+v", v) e.logger.WithLevel(zerolog.PanicLevel).
Interface("req", e.req).
log.Fatal().
Str("message", message).
Str("stack", string(stack)). Str("stack", string(stack)).
Msg("got HTTP panic") Msgf("request panic (500): %+v", v)
} }