mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
add TraceRoute feature on request logger
This commit is contained in:
parent
e98fd21c83
commit
35ab1de212
|
@ -359,6 +359,10 @@ Response:
|
||||||
|
|
||||||
Other Improvements:
|
Other Improvements:
|
||||||
|
|
||||||
|
- New `TraceRoute bool` on [request logger](https://github.com/kataras/iris/tree/master/middleware/logger) middleware. Displays information about the executed route, screenshot:
|
||||||
|
|
||||||
|
![logger middleware: TraceRoute screenshot](https://iris-go.com/images/github/logger-trace-route.png)
|
||||||
|
|
||||||
- Implement feature request [Log when I18n Translation Fails?](https://github.com/kataras/iris/issues/1593) by using the new `Application.I18n.DefaultMessageFunc` field **before** `I18n.Load`. [Example of usage](https://github.com/kataras/iris/blob/master/_examples/i18n/main.go#L28-L50).
|
- Implement feature request [Log when I18n Translation Fails?](https://github.com/kataras/iris/issues/1593) by using the new `Application.I18n.DefaultMessageFunc` field **before** `I18n.Load`. [Example of usage](https://github.com/kataras/iris/blob/master/_examples/i18n/main.go#L28-L50).
|
||||||
|
|
||||||
- Fix [#1594](https://github.com/kataras/iris/issues/1594) and add a new `PathAfterHandler` which can be set to true to enable the old behavior (not recommended though).
|
- Fix [#1594](https://github.com/kataras/iris/issues/1594) and add a new `PathAfterHandler` which can be set to true to enable the old behavior (not recommended though).
|
||||||
|
|
|
@ -19,6 +19,8 @@ func main() {
|
||||||
Path: true,
|
Path: true,
|
||||||
// Query appends the url query to the Path.
|
// Query appends the url query to the Path.
|
||||||
Query: true,
|
Query: true,
|
||||||
|
// Shows information about the executed route.
|
||||||
|
TraceRoute: true,
|
||||||
|
|
||||||
// Columns: true,
|
// Columns: true,
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,16 @@ type Config struct {
|
||||||
//
|
//
|
||||||
// Defaults to false.
|
// Defaults to false.
|
||||||
PathAfterHandler bool
|
PathAfterHandler bool
|
||||||
|
|
||||||
// Query will append the URL Query to the Path.
|
// Query will append the URL Query to the Path.
|
||||||
// Path should be true too.
|
// Path should be true too.
|
||||||
//
|
//
|
||||||
// Defaults to false.
|
// Defaults to false.
|
||||||
Query bool
|
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).
|
// 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
|
// If custom `LogFunc` has been provided then this field is useless and users should
|
||||||
|
@ -100,6 +104,7 @@ func DefaultConfig() Config {
|
||||||
Path: true,
|
Path: true,
|
||||||
PathAfterHandler: false,
|
PathAfterHandler: false,
|
||||||
Query: false,
|
Query: false,
|
||||||
|
TraceRoute: false,
|
||||||
Columns: false,
|
Columns: false,
|
||||||
LogFunc: nil,
|
LogFunc: nil,
|
||||||
LogFuncCtx: nil,
|
LogFuncCtx: nil,
|
||||||
|
|
|
@ -139,6 +139,10 @@ func (l *requestLoggerMiddleware) ServeHTTP(ctx *context.Context) {
|
||||||
} else {
|
} else {
|
||||||
ctx.Application().Logger().Info(line)
|
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,
|
// Columnize formats the given arguments as columns and returns the formatted output,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user