[log] Add debug logging to custom linter analyzers#44860
Conversation
Instrument five previously-uninstrumented custom Go analysis linters in
pkg/linters/ with the project's namespace-based logger (pkg/logger):
- httprespbodyclose
- largefunc
- deferinloop
- excessivefuncparams
- httpstatuscode
Each linter gains a package-level `log = logger.New("linters:<name>")`,
an entry log in run() (package path plus threshold where relevant), and a
report-site log at each diagnostic chokepoint. Logger arguments are
side-effect-free (already-computed locals and the pass.Pkg.Path() getter),
and calls are zero-overhead when DEBUG is unset.
These analyzers contain real AST control-flow logic but had no logging,
unlike pkg/workflow, pkg/parser and pkg/cli which are already fully
instrumented.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@copilot please run the Run: https://github.com/github/gh-aw/actions/runs/29140825710
|
PR-finisher pass complete.
Actions taken: Local validation passed with no code changes required. Hand-off: CI must be re-triggered by a maintainer (close/reopen PR, Still needed: Human review and CI re-trigger. |
|
Hey One thing that would help land this smoothly:
If you would like a hand, you can assign this prompt to your coding agent:
|
|
🎉 This pull request is included in a new release. Release: |
Summary
Adds structured debug logging to five custom Go linter analyzers using the shared
pkg/loggerpackage. No logic changes; this is a pure observability improvement.Changes
pkg/linters/deferinloop/deferinloop.golinters:deferinlooppkg/linters/excessivefuncparams/excessivefuncparams.golinters:excessivefuncparamspkg/linters/httprespbodyclose/httprespbodyclose.golinters:httprespbodyclosepkg/linters/httpstatuscode/httpstatuscode.golinters:httpstatuscodepkg/linters/largefunc/largefunc.golinters:largefuncEach analyzer receives:
var log = logger.New("linters:<name>")logger.log.Printf("analyzing package %s", pass.Pkg.Path())call at the start ofrun(). Configurable-threshold analyzers (excessivefuncparams,largefunc) also log the active threshold value.log.Printf(...)call immediately before each diagnostic emission, recording the position and nature of the finding.Motivation
Debug logging makes it possible to trace which packages each analyzer processes and which findings it emits without attaching a debugger, aiding development and CI triage.
Impact