From fa02c08f994ce7cd2c17e7a5c2683d2a271b5ee3 Mon Sep 17 00:00:00 2001 From: sashaodessa <140454972+sashaodessa@users.noreply.github.com> Date: Sun, 11 Jan 2026 13:18:41 +0100 Subject: [PATCH] Update logging.go --- api/proxy/servers/rest/middleware/logging.go | 21 ++++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/api/proxy/servers/rest/middleware/logging.go b/api/proxy/servers/rest/middleware/logging.go index 863d10d8fe..fdae10e807 100644 --- a/api/proxy/servers/rest/middleware/logging.go +++ b/api/proxy/servers/rest/middleware/logging.go @@ -29,18 +29,17 @@ func withLogging( "status", scw.status, "duration", time.Since(start), } - if err != nil { - args = append(args, "error", err.Error()) - if scw.status >= 400 && scw.status < 500 { - log.Warn("request completed with 4xx error", args...) - } else { - log.Error("request completed with error", args...) - } + // Success-path logging is handled by the handlers (e.g. "Processed request"). + // Keeping middleware logging only for error paths avoids duplicate log lines. + if err == nil { + return + } + + args = append(args, "error", err.Error()) + if scw.status >= 400 && scw.status < 500 { + log.Warn("request completed with 4xx error", args...) } else { - // This log line largely duplicates the logging in the handlers. - // Only difference being that we have duration here, whereas the handlers log the cert. - // TODO: should we also pass the cert via the requestContext to rid of the log lines in the handlers? - log.Info("request completed", args...) + log.Error("request completed with error", args...) } } }