mirror of
https://github.com/kataras/iris.git
synced 2026-01-04 18:57:03 +00:00
add TraceRoute feature on request logger
This commit is contained in:
@@ -37,12 +37,16 @@ type Config struct {
|
||||
//
|
||||
// Defaults to false.
|
||||
PathAfterHandler bool
|
||||
|
||||
// Query will append the URL Query to the Path.
|
||||
// Path should be true too.
|
||||
//
|
||||
// Defaults to false.
|
||||
Query bool
|
||||
// TraceRoute displays the debug
|
||||
// information about the current route executed.
|
||||
//
|
||||
// Defaults to false.
|
||||
TraceRoute bool
|
||||
|
||||
// Columns will display the logs as a formatted columns-rows text (bool).
|
||||
// If custom `LogFunc` has been provided then this field is useless and users should
|
||||
@@ -100,6 +104,7 @@ func DefaultConfig() Config {
|
||||
Path: true,
|
||||
PathAfterHandler: false,
|
||||
Query: false,
|
||||
TraceRoute: false,
|
||||
Columns: false,
|
||||
LogFunc: nil,
|
||||
LogFuncCtx: nil,
|
||||
|
||||
@@ -139,6 +139,10 @@ func (l *requestLoggerMiddleware) ServeHTTP(ctx *context.Context) {
|
||||
} else {
|
||||
ctx.Application().Logger().Info(line)
|
||||
}
|
||||
|
||||
if l.config.TraceRoute && ctx.GetCurrentRoute() != nil /* it is nil on unhandled error codes */ {
|
||||
ctx.GetCurrentRoute().Trace(ctx.Application().Logger().Printer)
|
||||
}
|
||||
}
|
||||
|
||||
// Columnize formats the given arguments as columns and returns the formatted output,
|
||||
|
||||
Reference in New Issue
Block a user