From ea10178216a204564ea0a27cd72785188d3a6bb7 Mon Sep 17 00:00:00 2001 From: Chance Zibolski Date: Wed, 7 Jun 2023 15:46:13 -0700 Subject: [PATCH] Fix logrus interceptor (#588) * interceptors: Fix logrus example to iterate over all fields Fixes https://github.com/grpc-ecosystem/go-grpc-middleware/issues/570 Signed-off-by: Chance Zibolski * interceptors: Update zap InterceptorLogger to use Iterator properly The logic in the example is redundant with the logging.Fields Iterator Signed-off-by: Chance Zibolski --------- Signed-off-by: Chance Zibolski --- interceptors/logging/examples/logrus/example_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interceptors/logging/examples/logrus/example_test.go b/interceptors/logging/examples/logrus/example_test.go index d0f232f8a..23e33a3b7 100644 --- a/interceptors/logging/examples/logrus/example_test.go +++ b/interceptors/logging/examples/logrus/example_test.go @@ -18,7 +18,7 @@ func InterceptorLogger(l logrus.FieldLogger) logging.Logger { return logging.LoggerFunc(func(_ context.Context, lvl logging.Level, msg string, fields ...any) { f := make(map[string]any, len(fields)/2) i := logging.Fields(fields).Iterator() - if i.Next() { + for i.Next() { k, v := i.At() f[k] = v }