-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Implementing grpclog.LoggerV2 compatible logger #538
Conversation
Codecov Report
@@ Coverage Diff @@
## master #538 +/- ##
=========================================
Coverage ? 97.41%
=========================================
Files ? 40
Lines ? 2128
Branches ? 0
=========================================
Hits ? 2073
Misses ? 47
Partials ? 8
Continue to review full report at Codecov.
|
print: (*zap.SugaredLogger).Info, | ||
printf: (*zap.SugaredLogger).Infof, | ||
log: l.Sugar(), | ||
info: (*zap.SugaredLogger).Info, |
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.
is there a reason why we have to keep function pointers for each level, instead of just doing l.sugar.Info(..)
etc?
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.
@prashantv no reason. I was just trying to maintain the programming style that was previously present.
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.
@prashantv this is for the WithDebug
function, which changes the zap function used for the Print
functions.
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.
Ah, I see. In that case, aren't the only functions we need to do this for print
and printf
? The rest should just be normal function calls on the Logger.
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.
That would work too, either/or, I was just being consistent, especially “back in the day” before this PR when there were only a few functions :-)
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'm sorry I missed this. The V implementation is incorrect. V does not correspond to log level, it can be things like 100. See https://godoc.org/github.com/golang/glog#Verbose and https://github.com/golang/glog/blob/master/glog.go#L999 for more details. This is why I didn't implement this originally as it was extra logic.
Also see https://github.com/grpc/grpc-go/blob/master/grpclog/loggerv2.go. It's not hard to implement, but it should be done in a thread-safe manner if you make V modifiable. glog does this. |
@peter-edge good catch. I'll fix the implementation. |
@frankgreco any progress on this? |
I fixed the V implementation in my repo. Can I overtake this PR? |
Yea! Sorry I haven’t had time to complete this. I’d be awesome if you could provide the V implementation! |
Thanks. I sent PR based on your commit, so please sign CLA. |
@frankgreco please sign CLA. That should take only a few minutes. |
Let's continue at #613. |
@AlekSi I think I fixed it :) I did an interactive rebase an modified the author/email for this commit to an email that was on my account (I don't have access to verify the original email as I no longer work for that company). As you will see, the CLA has been signed in this PR. Now, the reason it isn't signed in #613 is because that is off of @kazegusuri branch which does not have my modified commit. @kazegusuri can you update your branch so that you are using my modified commit? Then, we should all be good. Sorry that this was such a mess :( |
GRECO, FRANK seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Would be great to get this merged! @frankgreco Perhaps you could squash all commits and use the right email to commit it? |
gRPC has an updated [logger interface][1] that the v1 API has been deprecated in favor of. [1]: https://pkg.go.dev/google.golang.org/grpc/grpclog#LoggerV2 This adds support for it to the existing gRPC adapter in Zap. Fixes #534 Closes #538 Co-authored-by: Prashant Varanasi <github@prashantv.com> Co-authored-by: Abhinav Gupta <abg@uber.com>
gRPC has an updated [logger interface][1] that the v1 API has been deprecated in favor of. [1]: https://pkg.go.dev/google.golang.org/grpc/grpclog#LoggerV2 This adds support for it to the existing gRPC adapter in Zap. Fixes #534 Closes #538 Co-authored-by: Prashant Varanasi <github@prashantv.com> Co-authored-by: Abhinav Gupta <abg@uber.com>
gRPC has an updated [logger interface][1] that the v1 API has been deprecated in favor of. [1]: https://pkg.go.dev/google.golang.org/grpc/grpclog#LoggerV2 This adds support for it to the existing gRPC adapter in Zap. Fixes uber-go#534 Closes uber-go#538 Co-authored-by: Prashant Varanasi <github@prashantv.com> Co-authored-by: Abhinav Gupta <abg@uber.com>
Currently,
go.uber.org/zap/zapgrpc.Logger
only provides an implementation forgrpclog.Logger
. With the release ofgrpclog.LoggerV2
, an updated implementation is needed so thatgo.uber.org/zap/zapgrpc.Logger
implements bothgrpclog.Logger
andgrpclog.LoggerV2
.Fixes #534