Skip to content

refactor(logging): replace log.Printf with injected zap logger and remove dead code#171

Merged
xytan0056 merged 4 commits into
mainfrom
refactor-replace-log-printf-with-zap
Jul 10, 2026
Merged

refactor(logging): replace log.Printf with injected zap logger and remove dead code#171
xytan0056 merged 4 commits into
mainfrom
refactor-replace-log-printf-with-zap

Conversation

@xytan0056

@xytan0056 xytan0056 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

replace log.Printf with universal zap logger and thread the logger to call sites required
removed unused functions in ITG

Test plan

CI tests

@xytan0056 xytan0056 requested review from a team as code owners July 9, 2026 22:00
@xytan0056 xytan0056 closed this Jul 9, 2026
Comment thread core/git/git.go
// 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 {

@xytan0056 xytan0056 Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another option is to extract the logger from ctx, but I think it's more at the request scope, rather than for util module

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we should just move this entire pkg to internal. this looks fine for now.

@xytan0056 xytan0056 reopened this Jul 9, 2026
Comment thread core/itg/graph/graph.go Outdated
Comment thread core/itg/graph/graph.go Outdated
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)

@sywhang sywhang Jul 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@xytan0056 xytan0056 Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch . actually this is dead code.
removed.

xytan0056 added 3 commits July 9, 2026 17:29
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.
@xytan0056 xytan0056 changed the title refactor(logging): replace log.Printf with injected zap logger refactor(logging): replace log.Printf with injected zap logger and remove dead code Jul 10, 2026
@xytan0056 xytan0056 force-pushed the refactor-replace-log-printf-with-zap branch from 45e3ab5 to d655931 Compare July 10, 2026 00:34
@xytan0056 xytan0056 merged commit 7876d38 into main Jul 10, 2026
8 checks passed
@xytan0056 xytan0056 deleted the refactor-replace-log-printf-with-zap branch July 10, 2026 04:14
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.

2 participants