[log] Add debug logging to custom linter analyzers#44860
[log] Add debug logging to custom linter analyzers#44860github-actions[bot] wants to merge 1 commit into
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:
|
Summary
Adds namespace-based debug logging (
pkg/logger) to 5 custom Go analysis linters inpkg/linters/that previously had no instrumentation:pkg/linters/httprespbodyclose/httprespbodyclose.golinters:httprespbodyclosepkg/linters/largefunc/largefunc.golinters:largefuncpkg/linters/deferinloop/deferinloop.golinters:deferinlooppkg/linters/excessivefuncparams/excessivefuncparams.golinters:excessivefuncparamspkg/linters/httpstatuscode/httpstatuscode.golinters:httpstatuscodeEach file gets:
github.com/github/gh-aw/pkg/loggervar log = logger.New("linters:<name>")run()recording the package being analyzed (and themax-lines/max-paramsthreshold where applicable)Enable with e.g.
DEBUG=linters:*.Why these files
pkg/workflow,pkg/parserandpkg/cliare already comprehensively instrumented (the logger is used in 400+ files). The custom linters, by contrast, contain real AST control-flow logic but had zero logging, making them the highest-value remaining target. The pre-flight manifest'sfiles_needing_logger/missing_logger_importlists were stale — they flagged files that already log via shared package-scoped loggers (e.g.engine_validation.go,strict_mode_env_validation.go,agentdrain/*).Constraints honored
*_test.goortestdatafiles touched.pass.Pkg.Path()getter).logis not flagged by the repo's ownrawloginliblinter:IsPkgSelectorrequires a*types.PkgName, so a*logger.Loggervariable never matches.Validation limitation
make build/make fmtcould not be run in this environment: the installed Go is1.25.11butgo.modrequires>= 1.26.3underGOTOOLCHAIN=local, and the sandbox blocks changingGOTOOLCHAINor downloading a toolchain. This pre-existing limitation fails the entire module regardless of these edits. The changes are minimal and mirror the exact logger pattern used across 400+ existing files; please confirm CI is green before merging.🤖 Generated with [Claude Code]((claude.com/redacted)