-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: iter would no longer be inited every time in the loop #565
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks <3
One nit, otherwise LGTM - also CLA is required. Thanks!!
@@ -17,10 +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) | |||
iter := logging.Fields(fields).Iterator() | |||
for i := 0; i < len(fields); i += 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be simplified further, similar to https://github.com/grpc-ecosystem/go-grpc-middleware/blob/main/interceptors/logging/examples/logrus/example_test.go#L21
I messed this up 🙃 Can we double check other examples too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually needs to be for iter.Next()
. This issue seems to be present on all the examples.
Fixes #559 |
Also we need tests, but we can do them in later PRs (or here) - added issue to track this: #567 |
This should be fixed via #588 so I think this can be closed. |
Thanks! |
fix: iter would no longer be inited every time in the loop
Changes
Verification
I've used this code in my project, and the log looks good now