Skip to content

Commit

Permalink
Move access log to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Dec 27, 2023
1 parent 0fcf7f3 commit 5465d83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ func TestNewBaseLocator(t *testing.T) {
assert.Equal(t, `{"error":"request panicked"}`+"\n", rw.Body.String())

logs := "[" + strings.ReplaceAll(log.String(), "\n", ",\n") + "{}]"
assertjson.Equal(t, []byte(`[{"level":"info","@timestamp":"<ignore-diff>","message":"http request started","client.ip":"","user_agent.original":"","url.original":"/test/something-public","http.request.method":"GET"},
{"level":"error","@timestamp":"<ignore-diff>","message":"request panicked","panic":"oops","stack":"<ignore-diff>","client.ip":"","user_agent.original":"","url.original":"/test/something-public","http.request.method":"GET"},
assertjson.Equal(t, []byte(`[{"level":"error","@timestamp":"<ignore-diff>","message":"request panicked","panic":"oops","stack":"<ignore-diff>","client.ip":"","user_agent.original":"","url.original":"/test/something-public","http.request.method":"GET"},
{}]`), []byte(logs), logs)

l.Shutdown()
Expand Down
6 changes: 2 additions & 4 deletions log/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ func (mw HTTPRecover) Middleware() func(handler http.Handler) http.Handler {
fields.HTTPMethod, r.Method,
)

logger.Info(ctx, "http request started")
logger.Debug(ctx, "http request headers", "headers", headersMap(r.Header))
logger.Debug(ctx, "http request started", "headers", headersMap(r.Header))

w := middleware.NewWrapResponseWriter(rw, r.ProtoMajor)
start := time.Now()
Expand All @@ -148,8 +147,7 @@ func (mw HTTPRecover) Middleware() func(handler http.Handler) http.Handler {
"elapsed_ms", float64(elapsed.Nanoseconds())/1000000.0,
)

logger.Debug(ctx, "http response headers", "headers", headersMap(w.Header()))
logger.Info(ctx, "http request complete")
logger.Debug(ctx, "http request complete", "resp_headers", headersMap(w.Header()))
})
}
}
Expand Down

0 comments on commit 5465d83

Please sign in to comment.