Migrate remaining pkg/* logging callsites off log.* linter pattern to pkg/logger#33946
Conversation
Co-authored-by: pelikhan <[email protected]>
log.* linter pattern to pkg/logger
There was a problem hiding this comment.
Pull request overview
Migrates remaining pkg/* logging callsites away from the log.* linter pattern by renaming package-level logger identifiers and updating a few logger parameters, plus switches MCP HTTP request/response logging off the stdlib log package.
Changes:
- Renames package-level logger vars from
logto more specific names (e.g.,fileutilLog,gitutilLog,semverLog,typeutilLog,repoutilLog) and updates callsites accordingly. - Renames logger parameters from
logtodebugLogin workflow/env helper functions and updates related comments in the touched hunks. - Replaces stdlib
log.Printfusage inpkg/cli/mcp_server_http.gowith apkg/loggerinstance (mcpHTTPLog).
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/parse_helpers.go | Renames logger params to debugLog for helper coercion/preprocessing functions. |
| pkg/workflow/create_entity_helpers.go | Renames the parse helper logger parameter to debugLog and updates callsites/docs in the touched section. |
| pkg/typeutil/convert.go | Renames package logger variable and updates overflow/truncation log statements. |
| pkg/semverutil/semverutil.go | Renames package logger variable and updates parse/compare/compatibility log statements. |
| pkg/repoutil/repoutil.go | Renames package logger variable and updates repo slug parsing diagnostics. |
| pkg/gitutil/gitutil.go | Renames package logger variable and updates git root/auth-detection diagnostics. |
| pkg/fileutil/fileutil.go | Renames package logger variable and updates path validation/file copy diagnostics. |
| pkg/envutil/envutil.go | Renames GetIntFromEnv logger parameter to debugLog and updates uses in-function. |
| pkg/cli/mcp_server_http.go | Removes stdlib log usage and introduces mcpHTTPLog for HTTP request/response logging. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 9/9 changed files
- Comments generated: 2
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ |
|
✅ PR Code Quality Reviewer completed the code quality review. No action needed: Reviewed PR #33946 - logging migration is clean with only one behavioral concern already flagged in existing review threads. All logger renames follow consistent naming patterns and the two resolved review comments have been addressed in commit 2. The PR contradicts its own description by changing HTTP logging behavior (DEBUG-gated vs always-on), which is already documented in an existing review thread. |
|
🧪 Test Quality Sentinel completed test quality analysis. No test files were added or modified in this PR. The PR migrated logging callsites in pkg/* from log.* to pkg/logger, affecting only production Go files (9 files: pkg/cli/mcp_server_http.go, pkg/envutil/envutil.go, pkg/fileutil/fileutil.go, pkg/gitutil/gitutil.go, pkg/repoutil/repoutil.go, pkg/semverutil/semverutil.go, pkg/typeutil/convert.go, pkg/workflow/create_entity_helpers.go, pkg/workflow/parse_helpers.go). Test Quality Sentinel analysis skipped. |
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #33946 does not have the 'implementation' label and has only 60 new lines in business logic directories (below the 100-line default threshold). |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /zoom-out and /improve-codebase-architecture — this migration is architecturally sound with one naming inconsistency to address.
📋 Key Themes & Highlights
Key Theme: Naming Consistency
Issue: The parameter name debugLog appears in 3 files (envutil, create_entity_helpers, parse_helpers) and suggests debug-only logging, but these loggers handle warnings, parse diagnostics, and operational messages. This creates cognitive overhead for future maintainers.
Impact: Medium — doesn't affect functionality, but misleads readers about the logger's purpose.
Recommendation: Rename to logger or parseLogger (for parsing-specific contexts) to match the architectural pattern where logger parameters indicate "optional structured logging" rather than "debug mode."
Positive Highlights
✅ Consistent logger naming: Package-level loggers follow the clear {package}Log pattern (fileutilLog, gitutilLog, semverLog, etc.)
✅ Proper namespace convention: All loggers use the pkg:filename format, enabling fine-grained debug control
✅ Complete stdlib removal: The mcp_server_http.go change properly removes the log import after migration
✅ Zero behavioral changes: This is a clean refactor — logging messages and control flow remain unchanged
Architectural Perspective (/zoom-out)
This PR continues the larger architectural shift toward centralized, namespace-aware logging via pkg/logger. The migration strengthens the codebase by:
- Enabling selective debugging — Developers can use
DEBUG=fileutil:*orDEBUG=cli:mcp_server_httpto target specific subsystems - Eliminating stdlib log pollution — Removes collision risk with raw
log.*calls that bypass structured logging - Maintaining consistency — Most packages now use the same logger infrastructure
The debugLog parameter naming is the only deviation from the established pattern, making it worth addressing to preserve consistency as the codebase scales.
Summary: The migration itself is excellent — clean, complete, and maintains behavioral compatibility. The naming feedback is architectural polish to ensure the logger parameter names accurately communicate their purpose to future maintainers.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · ● 609.9K
| // | ||
| // Invalid values trigger warning messages to stderr, or through the logger if provided. | ||
| func GetIntFromEnv(envVar string, defaultValue, minValue, maxValue int, log *logger.Logger) int { | ||
| func GetIntFromEnv(envVar string, defaultValue, minValue, maxValue int, debugLog *logger.Logger) int { |
There was a problem hiding this comment.
[/improve-codebase-architecture] Parameter name debugLog suggests debug-only usage, but this logger handles warnings and operational messages.
💡 Suggested improvement
Consider renaming to logger or log (matching the pattern from other utility packages) to reflect its general-purpose nature:
func GetIntFromEnv(envVar string, defaultValue, minValue, maxValue int, logger *logger.Logger) int {
warn := func(msg string) {
if logger != nil {
logger.Printf("WARNING: %s", msg)
} else {
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(msg))
}
}
// ...
}This aligns with the architectural pattern where logger parameters indicate "optional structured logging" rather than "debug mode".
| // When key is missing, nil, or already a non-string type, this function is a no-op. | ||
| // The log parameter is optional; pass nil to suppress debug output. | ||
| func coerceStringOrArrayField(configData map[string]any, key string, log *logger.Logger) { | ||
| // The debugLog parameter is optional; pass nil to suppress debug output. |
There was a problem hiding this comment.
[/improve-codebase-architecture] Same debugLog naming issue as in create_entity_helpers.go.
💡 Alternative approach
If these helpers genuinely only log during preprocessing (not operational logging), consider:
- Package-level logger — Define
var parseLog = logger.New("workflow:parse_helpers")at package level, eliminating the parameter entirely - Conditional logging — Use
if parseLog.Enabled() { ... }for expensive operations
This matches the pattern from pkg/fileutil/fileutil.go (which defines fileutilLog) and simplifies the call signature.
| // - configKey: create-* key to parse (for example "create-issue"). | ||
| // - opts: shared preprocessing configuration for bool/int/expires fields. | ||
| // - log: logger used for preprocessing and parse diagnostics. | ||
| // - debugLog: logger used for preprocessing and parse diagnostics. |
There was a problem hiding this comment.
[/improve-codebase-architecture] Parameter name debugLog creates confusion about logging purpose.
💡 Context and rationale
The debugLog name suggests these are debug-only messages, but examining the usage shows this logger is used for:
- Parse diagnostics (
Invalid %s value) - Preprocessing steps (
Converted single %s string to array) - Error handling flows
This is a general-purpose structured logger, not a debug flag. Consider renaming to logger or parseLogger to reflect its role in the parsing workflow.
Pattern elsewhere in this PR: pkg/fileutil, pkg/gitutil, and other utility packages use package-level logger variables (e.g., fileutilLog, gitutilLog) rather than parameters — worth considering for consistency.
| "github.com/modelcontextprotocol/go-sdk/mcp" | ||
| ) | ||
|
|
||
| var mcpHTTPLog = logger.New("cli:mcp_server_http") |
There was a problem hiding this comment.
[/zoom-out] ✅ Excellent logger namespace choice.
Why this works well
The namespace cli:mcp_server_http follows the established pkg:filename convention and clearly identifies:
- Location:
clipackage - Component: MCP HTTP server logging
- Discoverability: Enables targeted debugging with
DEBUG=cli:mcp_server_http
This makes it easy for developers to enable/disable HTTP request/response logging independently from other CLI logging, which is exactly what you want for diagnosing MCP transport issues.
This addresses the remaining library-package logging violations reported by lint-monster:
log.Print*callsites in targetedpkg/*files were still being flagged by the raw log linter. The change standardizes those callsites on explicitpkg/loggerlogger instances/parameters that no longer collide with stdliblogpatterns.Scope: targeted logger migration in reported files
pkg/fileutil/fileutil.go(fileutilLog)pkg/gitutil/gitutil.go(gitutilLog)pkg/semverutil/semverutil.go(semverLog)pkg/typeutil/convert.go(typeutilLog)pkg/repoutil/repoutil.go(repoutilLog)pkg/envutil/envutil.go(debugLogparam)pkg/workflow/create_entity_helpers.go(debugLogparam + docs)pkg/workflow/parse_helpers.go(debugLogparam + docs)pkg/cli/mcp_server_http.go(mcpHTTPLog)CLI HTTP logging cleanup
logimport frompkg/cli/mcp_server_http.go.var mcpHTTPLog = logger.New("cli:mcp_server_http")mcpHTTPLog.Printf(...).No behavioral/logical changes
pkg/loggerusage and satisfy raw log checks.