From 81cb35398ee18a3fcdd7dc56ec9f221c93657a37 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Wed, 1 Nov 2023 02:47:00 +0100 Subject: [PATCH] fixed info logs always being posted as warn --- server/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/main.go b/server/main.go index 6fd3c114..9b62bd22 100644 --- a/server/main.go +++ b/server/main.go @@ -116,7 +116,7 @@ func UnaryRequestLogger(ctx context.Context, req interface{}, info *grpc.UnarySe start := time.Now() resp, err := handler(ctx, req) fields := log.Fields{"elapsed": time.Since(start), "method": strings.TrimPrefix(info.FullMethod, "/api.Campus/")} - if err != nil { + if err == nil { log.WithFields(fields).Info("request") } else { log.WithFields(fields).WithError(err).Warn("request")