diff --git a/logging_handler_test.go b/logging_handler_test.go index b036a1f..0adec08 100644 --- a/logging_handler_test.go +++ b/logging_handler_test.go @@ -24,6 +24,7 @@ func TestLoggingHandler_ServeHTTP(t *testing.T) { {logger.DefaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/foo/bar\" HTTP/1.1 \"\" 200 4 0.000\n", logger.FormatTimestamp(ts)), "/foo/bar", ""}, {logger.DefaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/foo/bar\" HTTP/1.1 \"\" 200 4 0.000\n", logger.FormatTimestamp(ts)), "/foo/bar", "/ping"}, {logger.DefaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/ping\" HTTP/1.1 \"\" 200 4 0.000\n", logger.FormatTimestamp(ts)), "/ping", ""}, + {logger.DefaultRequestLoggingFormat, "", "/ping", "/ping"}, {"{{.RequestMethod}}", "GET\n", "/foo/bar", ""}, {"{{.RequestMethod}}", "GET\n", "/foo/bar", "/ping"}, {"{{.RequestMethod}}", "GET\n", "/ping", ""}, diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 68149c7..89b8450 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -182,6 +182,7 @@ func (l *Logger) PrintReq(username, upstream string, req *http.Request, url url. if url.Path == l.excludePath { return } + duration := float64(time.Now().Sub(ts)) / float64(time.Second) if username == "" {