diff --git a/internal/middleware/logger.go b/internal/middleware/logger.go index c98fc9d3..e42b7a51 100644 --- a/internal/middleware/logger.go +++ b/internal/middleware/logger.go @@ -55,7 +55,8 @@ func LoggerMiddleware(rootLogger *zerolog.Logger) func(next http.Handler) http.H log.Error(). Bool("panic", true). Int("status", panicStatus). - Msgf("Unhandled panic: %s\n%s", rec, debug.Stack()) + Bytes("stacktrace", debug.Stack()). + Msgf("Unhandled panic in API: %s", rec) http.Error(ww, http.StatusText(panicStatus), panicStatus) } diff --git a/pkg/worker/redis.go b/pkg/worker/redis.go index c3060934..bb0fa30f 100644 --- a/pkg/worker/redis.go +++ b/pkg/worker/redis.go @@ -165,13 +165,10 @@ func (w *RedisWorker) dequeueLoop(ctx context.Context, i, total int) { func recoverAndLog(ctx context.Context) { if rec := recover(); rec != nil { - logger := zerolog.Ctx(ctx).Error() - - if err, ok := rec.(error); ok { - logger.Err(err).Stack().Msg("Job queue panic") - } else { - logger.Msgf("Error during job handling: %v, stacktrace: %s", rec, debug.Stack()) - } + zerolog.Ctx(ctx).Error(). + Bool("panic", true). + Bytes("stacktrace", debug.Stack()). + Msgf("Unhandled panic in worker: %s", rec) } }