1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-22 04:17:03 +00:00

accesslog: log error bodies and communicate with the recover middleware

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-10 14:47:14 +03:00
parent cf0338d342
commit ae67987f55
7 changed files with 142 additions and 15 deletions

View File

@@ -41,12 +41,13 @@ func New() context.Handler {
// when stack finishes
logMessage := fmt.Sprintf("Recovered from a route's Handler('%s')\n", ctx.HandlerName())
logMessage += fmt.Sprintf("At Request: %s\n", getRequestLogs(ctx))
logMessage += fmt.Sprintf("Trace: %s\n", err)
logMessage += fmt.Sprintf("\n%s", stacktrace)
logMessage += fmt.Sprint(getRequestLogs(ctx))
logMessage += fmt.Sprintf("%s\n", err)
logMessage += fmt.Sprintf("%s\n", stacktrace)
ctx.Application().Logger().Warn(logMessage)
ctx.StopWithStatus(500)
// see accesslog.isPanic too.
ctx.StopWithPlainError(500, context.ErrPanicRecovery{Cause: err, Stacktrace: stacktrace})
}
}()