Skip to content

Commit

Permalink
πŸ”„ Sync from monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
mojo-machine[bot] committed Nov 30, 2023
1 parent 63f5f36 commit 4e59732
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/middleware/request/logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package request

import (
"context"
"net/http"
"time"

Expand Down Expand Up @@ -90,9 +91,11 @@ func Logger(log *logrus.Entry) func(http.Handler) http.Handler {
"http_response_bytes": res.Bytes,
})

fn := mlog.Info
err := getError(clog.Get(ctx))
if err != nil {
if err == nil {
mlog.Info(ctx, merr.New(ctx, "request_completed", nil))
} else {
var fn func(context.Context, merr.Merrer)
switch clog.DetermineLevel(err, clog.TimeoutsAsErrors(ctx)) {
case
logrus.PanicLevel,
Expand All @@ -108,9 +111,9 @@ func Logger(log *logrus.Entry) func(http.Handler) http.Handler {
logrus.TraceLevel:
fn = mlog.Info
}
}

fn(ctx, merr.New(ctx, "request", nil))
fn(ctx, merr.New(ctx, "request_failed", nil, err))
}
})
}
}
Expand Down

0 comments on commit 4e59732

Please sign in to comment.