From 4e597325ea65e63a27fde0407f73715975b89ac3 Mon Sep 17 00:00:00 2001 From: "mojo-machine[bot]" <111131124+mojo-machine[bot]@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:49:43 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20Sync=20from=20monorepo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/wearemojo/mojo/commit/f3a126a6327e81efada38574202b15bedc888a49 --- lib/middleware/request/logger.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/middleware/request/logger.go b/lib/middleware/request/logger.go index aa9f377..a54160d 100644 --- a/lib/middleware/request/logger.go +++ b/lib/middleware/request/logger.go @@ -1,6 +1,7 @@ package request import ( + "context" "net/http" "time" @@ -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, @@ -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)) + } }) } }