Use a warning log when request context canceled (#279)
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Nick Mills-Barrett 2024-09-03 13:54:10 +01:00 committed by GitHub
commit da2780bcbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -324,7 +324,9 @@ func (cli *Client) RequestStart(req *http.Request) {
func (cli *Client) LogRequestDone(req *http.Request, resp *http.Response, err error, handlerErr error, contentLength int, duration time.Duration) {
var evt *zerolog.Event
if err != nil {
if errors.Is(err, context.Canceled) {
evt = zerolog.Ctx(req.Context()).Warn()
} else if err != nil {
evt = zerolog.Ctx(req.Context()).Err(err)
} else if handlerErr != nil {
evt = zerolog.Ctx(req.Context()).Warn().
@ -357,7 +359,9 @@ func (cli *Client) LogRequestDone(req *http.Request, resp *http.Response, err er
if body := req.Context().Value(LogBodyContextKey); body != nil {
evt.Interface("req_body", body)
}
if err != nil {
if errors.Is(err, context.Canceled) {
evt.Msg("Request canceled")
} else if err != nil {
evt.Msg("Request failed")
} else if handlerErr != nil {
evt.Msg("Request parsing failed")