-
Notifications
You must be signed in to change notification settings - Fork 356
chore: unified logger print #2456
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
Signed-off-by: ashing <axingfly@gmail.com>
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 standardizes logging calls across the codebase by replacing ad-hoc concatenation and format strings with structured logging (Debugw, Errorw, Info, etc.) and zap fields. It also updates the signature of ProcessGatewayProxy
to accept a logr.Logger
.
- Replaced
log.Debug
,log.Debugf
,log.Errorf
,log.Infow
with structuredlog.Debugw
,log.Errorw
,r.Log.Error
, etc. - Added zap field arguments (
zap.String
,zap.Any
,zap.Error
, etc.) for better context. - Updated
ProcessGatewayProxy
signature and its call sites to includer.Log
.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/e2e/scaffold/adc.go | Switched log.Debug to log.Debugw |
internal/provider/adc/translator/httproute.go | Replaced log.Errorf with log.Errorw |
internal/provider/adc/translator/gateway.go | Converted log.Error to log.Errorw |
internal/provider/adc/translator/apisixroute.go | Added zap import and switched log.Debugf to log.Debugw |
internal/provider/adc/store.go | Replaced log.Debugf /log.Errorf with structured logs |
internal/provider/adc/executor.go | Used log.Debugw in place of log.Debug /log.Debugf |
internal/provider/adc/config.go | Switched log.Debugf to log.Debugw |
internal/provider/adc/adc.go | Replaced log.Debugf with log.Debugw |
internal/controller/utils.go | Updated log.Warnf to log.Warnw , changed ProcessGatewayProxy signature |
internal/controller/*.go | Updated various controllers to call ProcessGatewayProxy with r.Log |
Comments suppressed due to low confidence (2)
internal/provider/adc/store.go:58
- [nitpick] Log message ends with 'for' without context; consider changing to "Inserting resources into cache" and renaming the field key from "name" to something more descriptive like "cacheName".
log.Debugw("Inserting resources into cache for", zap.String("name", name))
internal/provider/adc/store.go:199
- [nitpick] Field key contains a space ("global rule"); consider using camelCase (e.g., "globalRuleID") to keep field names consistent.
log.Errorw("failed to delete global rule", zap.Error(err), zap.String("global rule", globalRule.ID))
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: ashing <axingfly@gmail.com>
Signed-off-by: ashing <axingfly@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Type of change:
What this PR does / why we need it:
Uniformly handle logger printing and formatting
Previously, it was incorrect to concatenate strings together due to improper use of the logger.
Pre-submission checklist: