Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Migrate remaining pkg/* logging callsites off log.* linter pattern to pkg/logger#33946

Merged
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-migrate-logging
May 22, 2026
Merged

Migrate remaining pkg/* logging callsites off log.* linter pattern to pkg/logger#33946
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-migrate-logging

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

This addresses the remaining library-package logging violations reported by lint-monster: log.Print* callsites in targeted pkg/* files were still being flagged by the raw log linter. The change standardizes those callsites on explicit pkg/logger logger instances/parameters that no longer collide with stdlib log patterns.

  • Scope: targeted logger migration in reported files

    • Updated logger identifiers/params in:
      • 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 (debugLog param)
      • pkg/workflow/create_entity_helpers.go (debugLog param + docs)
      • pkg/workflow/parse_helpers.go (debugLog param + docs)
      • pkg/cli/mcp_server_http.go (mcpHTTPLog)
  • CLI HTTP logging cleanup

    • Removed stdlib log import from pkg/cli/mcp_server_http.go.
    • Added package logger declaration:
      • var mcpHTTPLog = logger.New("cli:mcp_server_http")
    • Switched request/response logging to mcpHTTPLog.Printf(...).
  • No behavioral/logical changes

    • Logging messages and control flow remain unchanged; this is a naming/import migration to align with pkg/logger usage and satisfy raw log checks.
// before
import "log"
log.Printf("[REQUEST] %s | %s | %s %s", ...)

// after
var mcpHTTPLog = logger.New("cli:mcp_server_http")
mcpHTTPLog.Printf("[REQUEST] %s | %s | %s %s", ...)

Copilot AI changed the title [WIP] Migrate library package logging from log.Print* to pkg/logger Migrate remaining pkg/* logging callsites off log.* linter pattern to pkg/logger May 22, 2026
Copilot AI requested a review from pelikhan May 22, 2026 06:03
@github-actions github-actions Bot mentioned this pull request May 22, 2026
@pelikhan pelikhan marked this pull request as ready for review May 22, 2026 11:57
Copilot AI review requested due to automatic review settings May 22, 2026 11:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 log to more specific names (e.g., fileutilLog, gitutilLog, semverLog, typeutilLog, repoutilLog) and updates callsites accordingly.
  • Renames logger parameters from log to debugLog in workflow/env helper functions and updates related comments in the touched hunks.
  • Replaces stdlib log.Printf usage in pkg/cli/mcp_server_http.go with a pkg/logger instance (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

Comment thread pkg/envutil/envutil.go
Comment thread pkg/cli/mcp_server_http.go
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

🧪 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

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).

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

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:

  1. Enabling selective debugging — Developers can use DEBUG=fileutil:* or DEBUG=cli:mcp_server_http to target specific subsystems
  2. Eliminating stdlib log pollution — Removes collision risk with raw log.* calls that bypass structured logging
  3. 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

Comment thread pkg/envutil/envutil.go
//
// 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 {
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.

[/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.
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.

[/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:

  1. Package-level logger — Define var parseLog = logger.New("workflow:parse_helpers") at package level, eliminating the parameter entirely
  2. 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.
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.

[/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")
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.

[/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:

  1. Location: cli package
  2. Component: MCP HTTP server logging
  3. 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.

@pelikhan pelikhan merged commit e6cc9e6 into main May 22, 2026
73 of 87 checks passed
@pelikhan pelikhan deleted the copilot/lint-monster-migrate-logging branch May 22, 2026 12:34
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.

[lint-monster] Migrate library package logging from log.Print* to pkg/logger

3 participants