mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
Update to 8.0.4 | New: transfer a message to the request logger
Former-commit-id: 2bab3c9f28f7e9edd5d85e579349f70388af871d
This commit is contained in:
@@ -18,6 +18,11 @@ func main() {
|
||||
Method: true,
|
||||
// Path displays the request path
|
||||
Path: true,
|
||||
// Columns: true,
|
||||
|
||||
// if !empty then its contents derives from `ctx.Values().Get("logger_message")
|
||||
// will be added to the logs.
|
||||
MessageContextKey: "logger_message",
|
||||
})
|
||||
|
||||
app.Use(customLogger)
|
||||
@@ -40,6 +45,10 @@ func main() {
|
||||
*/
|
||||
// or catch all http errors:
|
||||
app.OnAnyErrorCode(customLogger, func(ctx context.Context) {
|
||||
// this should be added to the logs, at the end because of the `logger.Config#MessageContextKey`
|
||||
ctx.Values().Set("logger_message",
|
||||
"a dynamic message passed to the logs")
|
||||
|
||||
ctx.Writef("My Custom error page")
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user