From 3dc247893e9772d0b95c47f4b32dad3d28feb488 Mon Sep 17 00:00:00 2001 From: Adam Zielinski Date: Wed, 6 Mar 2019 20:47:31 -0500 Subject: [PATCH 1/3] make context.Keys available as LogFormatterParams (#1779) * make context available as LogFormatterParams * pass context Keys to LogFormatterParams * update logger test to check for Key param --- logger.go | 3 +++ logger_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/logger.go b/logger.go index dc639975..2ecaed7d 100644 --- a/logger.go +++ b/logger.go @@ -66,6 +66,8 @@ type LogFormatterParams struct { IsTerm bool // BodySize is the size of the Response Body BodySize int + // Keys are the keys set on the request's context. + Keys map[string]interface{} } // StatusCodeColor is the ANSI color for appropriately logging http status code to a terminal. @@ -227,6 +229,7 @@ func LoggerWithConfig(conf LoggerConfig) HandlerFunc { param := LogFormatterParams{ Request: c.Request, IsTerm: isTerm, + Keys: c.Keys, } // Stop timer diff --git a/logger_test.go b/logger_test.go index c551677a..a2041773 100644 --- a/logger_test.go +++ b/logger_test.go @@ -181,6 +181,7 @@ func TestLoggerWithFormatter(t *testing.T) { func TestLoggerWithConfigFormatting(t *testing.T) { var gotParam LogFormatterParams + var gotKeys map[string]interface{} buffer := new(bytes.Buffer) router := New() @@ -204,6 +205,7 @@ func TestLoggerWithConfigFormatting(t *testing.T) { router.GET("/example", func(c *Context) { // set dummy ClientIP c.Request.Header.Set("X-Forwarded-For", "20.20.20.20") + gotKeys = c.Keys }) performRequest(router, "GET", "/example?a=100") @@ -223,6 +225,8 @@ func TestLoggerWithConfigFormatting(t *testing.T) { assert.Equal(t, "GET", gotParam.Method) assert.Equal(t, "/example?a=100", gotParam.Path) assert.Empty(t, gotParam.ErrorMessage) + assert.Empty(t, gotParam.ErrorMessage) + assert.Equal(t, gotKeys, gotParam.Keys) } From f7079a861e6db66385aae1d865b9c9bbe10d1bb1 Mon Sep 17 00:00:00 2001 From: Sai Date: Fri, 8 Mar 2019 20:44:39 +0900 Subject: [PATCH 2/3] Delete dupilicated test (#1801) --- logger_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/logger_test.go b/logger_test.go index a2041773..36231371 100644 --- a/logger_test.go +++ b/logger_test.go @@ -225,7 +225,6 @@ func TestLoggerWithConfigFormatting(t *testing.T) { assert.Equal(t, "GET", gotParam.Method) assert.Equal(t, "/example?a=100", gotParam.Path) assert.Empty(t, gotParam.ErrorMessage) - assert.Empty(t, gotParam.ErrorMessage) assert.Equal(t, gotKeys, gotParam.Keys) } From 70a0aba3e423246be37462cfdaedd510c26c566e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=AC=A7?= Date: Fri, 8 Mar 2019 23:18:52 +0800 Subject: [PATCH 3/3] travisci: use go module when go11+ (#1800) --- .travis.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00393750..b38adcb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,20 @@ language: go sudo: false -go: - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - - 1.11.x - - 1.12.x - - master matrix: fast_finish: true include: + - go: 1.6.x + - go: 1.7.x + - go: 1.8.x + - go: 1.9.x + - go: 1.10.x - go: 1.11.x env: GO111MODULE=on - go: 1.12.x env: GO111MODULE=on + - go: master + env: GO111MODULE=on git: depth: 10