diff --git a/interceptors/logging/examples/logrus/example_test.go b/interceptors/logging/examples/logrus/example_test.go index beb8ad843..1cb38ebf0 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 } diff --git a/interceptors/logging/examples/zap/example_test.go b/interceptors/logging/examples/zap/example_test.go index 88a7b0d77..1b682d5a0 100644 --- a/interceptors/logging/examples/zap/example_test.go +++ b/interceptors/logging/examples/zap/example_test.go @@ -17,12 +17,10 @@ import ( func InterceptorLogger(l *zap.Logger) logging.Logger { return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) { f := make([]zap.Field, 0, len(fields)/2) - for i := 0; i < len(fields); i += 2 { - i := logging.Fields(fields).Iterator() - if i.Next() { - k, v := i.At() - f = append(f, zap.Any(k, v)) - } + i := logging.Fields(fields).Iterator() + for i.Next() { + k, v := i.At() + f = append(f, zap.Any(k, v)) } l = l.WithOptions(zap.AddCallerSkip(1)).With(f...)