-
Notifications
You must be signed in to change notification settings - Fork 257
Add v2 zap logger to cns apis #4003
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
Conversation
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.
Pull Request Overview
This PR adds zap logger v2 support to CNS APIs by plumbing the logger through the service configuration. The change addresses deprecation warnings for the global logger.Printf method by providing a structured logger instance to CNS services.
- Adds Logger field to ServiceConfig and Service structs to carry the zap logger
- Initializes the logger in the main service configuration
- Sets up the logger during service initialization
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
cns/service/main.go | Assigns the zap logger instance to the service config |
cns/common/service.go | Adds Logger field to ServiceConfig and Service structs and initializes it |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
what if V2 Logger is not enabled? Maybe we need a V1asV2
shim for migration?
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
I see we now have a zap logger v2 for cns
In #4002. I am getting:
SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
So this PR is to introduce the zap v2 logger into CNS APIs, by plumbing it through the CNS service config
Thoughts?
This would make
azure-container-networking/cns/restserver/api.go
Line 48 in f636b50
Into something like this:
I understand we already have a way to make
logger.Printf()
to point to a v2 zap logger underneath:azure-container-networking/cns/service/main.go
Lines 650 to 653 in f636b50
But this is more about when adding new APIs, and to avoid the linting errors