Skip to content

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

Merged
merged 7 commits into from
Jul 5, 2025
Merged

Conversation

ronething
Copy link
Contributor

@ronething ronething commented Jul 5, 2025

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches
  • Documentation
  • Refactor
  • Chore
  • CI/CD or Tests

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.

image

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

ronething added 3 commits July 5, 2025 10:02
Signed-off-by: ashing <axingfly@gmail.com>
Signed-off-by: ashing <axingfly@gmail.com>
@ronething ronething requested a review from Copilot July 5, 2025 03:01
Copy link
Contributor

@Copilot Copilot AI left a 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 structured log.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 include r.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))

ronething and others added 4 commits July 5, 2025 11:11
Signed-off-by: ashing <axingfly@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: ashing <axingfly@gmail.com>
@ronething ronething requested review from nic-6443 and AlinsRan July 5, 2025 05:07
@ronething ronething merged commit 8a2b2b1 into apache:master Jul 5, 2025
23 checks passed
@ronething ronething deleted the chore/fix_log branch July 5, 2025 14:22
AlinsRan pushed a commit that referenced this pull request Jul 7, 2025
Signed-off-by: ashing <axingfly@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants