refactor(logging): replace log.Printf with injected zap logger and remove dead code#171
Merged
Merged
Conversation
xytan0056
commented
Jul 9, 2026
| // New creates new Git interface implementation. A nil logger is tolerated and | ||
| // discards log output. | ||
| func New(directory string, logger *zap.SugaredLogger) Interface { | ||
| if logger == nil { |
Contributor
Author
There was a problem hiding this comment.
another option is to extract the logger from ctx, but I think it's more at the request scope, rather than for util module
Contributor
There was a problem hiding this comment.
ideally we should just move this entire pkg to internal. this looks fine for now.
xytan0056
commented
Jul 9, 2026
sywhang
reviewed
Jul 9, 2026
| targetID, ok := g.TargetNameToID[targetName] | ||
| if !ok { | ||
| log.Printf("starting target %s is not in the graph", targetName) | ||
| logger.Warnw("starting target is not in the graph", "target", targetName) |
Contributor
There was a problem hiding this comment.
if this call site is the only place we're logging something...... but hang on, do we want to log here or explicitly error out? when does this even occur?
Contributor
Author
There was a problem hiding this comment.
good catch . actually this is dead code.
removed.
The git package and itg/graph used the stdlib log.Printf for best-effort skip warnings instead of the zap logger threaded through the rest of the service. - core/git: inject a *zap.SugaredLogger into the git impl via New (nil-safe, defaults to a no-op logger). The two FileHashes parse-skip warnings now use logger.Warnw. The GitFactory seam is unchanged: callers capture the logger in a closure at the wiring sites. - core/itg/graph: drop the log.Printf in GetReverseDepsAsTargets. It was a caller-input condition already handled by the continue, on a test-only path, so no logger is added to the OptimizedGraph data struct.
Match the struct field and param names for consistency.
GetReverseDepsAsTargets (and its private helper getNewReverseDeps) had no non-test callers. Remove them along with their tests.
45e3ab5 to
d655931
Compare
sywhang
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
replace
log.Printfwith universal zap logger and thread the logger to call sites requiredremoved unused functions in ITG
Test plan
CI tests