diff options
author | Wim <wim@42.be> | 2017-06-06 00:01:05 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-06-06 00:04:18 +0200 |
commit | 3a183cb218c6812964a70d2e75884ad7071d9c0c (patch) | |
tree | ee0d2492c27e84ace88acfcfdc533545f42ccb21 /vendor/github.com/labstack/echo/middleware/logger.go | |
parent | 2eecaccd1c77e8990a80e6b4b6ad6b13a9c95896 (diff) | |
download | matterbridge-msglm-3a183cb218c6812964a70d2e75884ad7071d9c0c.tar.gz matterbridge-msglm-3a183cb218c6812964a70d2e75884ad7071d9c0c.tar.bz2 matterbridge-msglm-3a183cb218c6812964a70d2e75884ad7071d9c0c.zip |
Update vendor
Diffstat (limited to 'vendor/github.com/labstack/echo/middleware/logger.go')
-rw-r--r-- | vendor/github.com/labstack/echo/middleware/logger.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/vendor/github.com/labstack/echo/middleware/logger.go b/vendor/github.com/labstack/echo/middleware/logger.go index e26b5496..b9c54468 100644 --- a/vendor/github.com/labstack/echo/middleware/logger.go +++ b/vendor/github.com/labstack/echo/middleware/logger.go @@ -26,7 +26,7 @@ type ( // - time_unix_nano // - time_rfc3339 // - time_rfc3339_nano - // - id (Request ID - Not implemented) + // - id (Request ID) // - remote_ip // - uri // - host @@ -62,7 +62,7 @@ var ( // DefaultLoggerConfig is the default Logger middleware config. DefaultLoggerConfig = LoggerConfig{ Skipper: DefaultSkipper, - Format: `{"time":"${time_rfc3339_nano}","remote_ip":"${remote_ip}","host":"${host}",` + + Format: `{"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}","host":"${host}",` + `"method":"${method}","uri":"${uri}","status":${status}, "latency":${latency},` + `"latency_human":"${latency_human}","bytes_in":${bytes_in},` + `"bytes_out":${bytes_out}}` + "\n", @@ -126,6 +126,12 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc { return buf.WriteString(time.Now().Format(time.RFC3339)) case "time_rfc3339_nano": return buf.WriteString(time.Now().Format(time.RFC3339Nano)) + case "id": + id := req.Header.Get(echo.HeaderXRequestID) + if id == "" { + id = res.Header().Get(echo.HeaderXRequestID) + } + return buf.WriteString(id) case "remote_ip": return buf.WriteString(c.RealIP()) case "host": @@ -177,6 +183,11 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc { return buf.Write([]byte(c.QueryParam(tag[6:]))) case strings.HasPrefix(tag, "form:"): return buf.Write([]byte(c.FormValue(tag[5:]))) + case strings.HasPrefix(tag, "cookie:"): + cookie, err := c.Cookie(tag[7:]) + if err == nil { + return buf.Write([]byte(cookie.Value)) + } } } return 0, nil |