mirror of
https://github.com/kataras/iris.git
synced 2025-03-15 05:26:26 +01:00
middleware/logger: new configuration field, defaults to false: Query bool
, if true prints the full path, including the URL query as requested at https://github.com/kataras/iris/issues/1017
Former-commit-id: 03c8fc523a8ba955dae43e4c7e9498fc3d86a1c8
This commit is contained in:
parent
5de17a08f9
commit
f84248cb4e
|
@ -17,6 +17,8 @@ func main() {
|
||||||
Method: true,
|
Method: true,
|
||||||
// Path displays the request path
|
// Path displays the request path
|
||||||
Path: true,
|
Path: true,
|
||||||
|
// Query appends the url query to the Path.
|
||||||
|
Query: true,
|
||||||
|
|
||||||
//Columns: true,
|
//Columns: true,
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@ type Config struct {
|
||||||
// Defaults to true.
|
// Defaults to true.
|
||||||
Path bool
|
Path bool
|
||||||
|
|
||||||
|
// Query will append the URL Query to the Path.
|
||||||
|
// Path should be true too.
|
||||||
|
//
|
||||||
|
// Defaults to false.
|
||||||
|
Query 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
|
||||||
// use the `Columinize` function of the logger to get the output result as columns.
|
// use the `Columinize` function of the logger to get the output result as columns.
|
||||||
|
@ -81,6 +87,7 @@ func DefaultConfig() Config {
|
||||||
IP: true,
|
IP: true,
|
||||||
Method: true,
|
Method: true,
|
||||||
Path: true,
|
Path: true,
|
||||||
|
Query: false,
|
||||||
Columns: false,
|
Columns: false,
|
||||||
LogFunc: nil,
|
LogFunc: nil,
|
||||||
Skippers: nil,
|
Skippers: nil,
|
||||||
|
|
|
@ -66,8 +66,12 @@ func (l *requestLoggerMiddleware) ServeHTTP(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.config.Path {
|
if l.config.Path {
|
||||||
|
if l.config.Query {
|
||||||
|
path = ctx.Request().URL.RequestURI()
|
||||||
|
} else {
|
||||||
path = ctx.Path()
|
path = ctx.Path()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var message interface{}
|
var message interface{}
|
||||||
if ctxKeys := l.config.MessageContextKeys; len(ctxKeys) > 0 {
|
if ctxKeys := l.config.MessageContextKeys; len(ctxKeys) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user