-
Notifications
You must be signed in to change notification settings - Fork 400
Migrate remaining pkg/* logging callsites off log.* linter pattern to pkg/logger
#33946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,10 +27,10 @@ import ( | |
| // - Value is outside the [minValue, maxValue] range | ||
| // | ||
| // 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 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/improve-codebase-architecture] Parameter name 💡 Suggested improvementConsider renaming to 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". |
||
| warn := func(msg string) { | ||
| if log != nil { | ||
| log.Printf("WARNING: %s", msg) | ||
| if debugLog != nil { | ||
|
pelikhan marked this conversation as resolved.
|
||
| debugLog.Printf("WARNING: %s", msg) | ||
| } else { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(msg)) | ||
| } | ||
|
|
@@ -52,8 +52,8 @@ func GetIntFromEnv(envVar string, defaultValue, minValue, maxValue int, log *log | |
| return defaultValue | ||
| } | ||
|
|
||
| if log != nil { | ||
| log.Printf("Using %s=%d", envVar, val) | ||
| if debugLog != nil { | ||
| debugLog.Printf("Using %s=%d", envVar, val) | ||
| } | ||
| return val | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ type CreateParseOptions struct { | |
| // - outputMap: full safe-output map from frontmatter parsing. | ||
| // - 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/improve-codebase-architecture] Parameter name 💡 Context and rationaleThe
This is a general-purpose structured logger, not a debug flag. Consider renaming to Pattern elsewhere in this PR: |
||
| // - onError: required error handler invoked on unmarshal failures. | ||
| // | ||
| // Callback lifecycle: | ||
|
|
@@ -33,7 +33,7 @@ func parseCreateEntityConfig[T any]( | |
| outputMap map[string]any, | ||
| configKey string, | ||
| opts CreateParseOptions, | ||
| log *logger.Logger, | ||
| debugLog *logger.Logger, | ||
| onError func(error) *T, | ||
| preUnmarshal func(map[string]any) bool, | ||
| postUnmarshal func(map[string]any, *T, bool), | ||
|
|
@@ -53,24 +53,24 @@ func parseCreateEntityConfig[T any]( | |
|
|
||
| expiresDisabled := false | ||
| if opts.HandleExpires { | ||
| expiresDisabled = preprocessExpiresField(configData, log) | ||
| expiresDisabled = preprocessExpiresField(configData, debugLog) | ||
| } | ||
|
|
||
| for _, field := range opts.BoolFields { | ||
| if err := preprocessBoolFieldAsString(configData, field, log); err != nil { | ||
| log.Printf("Invalid %s value: %v", field, err) | ||
| if err := preprocessBoolFieldAsString(configData, field, debugLog); err != nil { | ||
| debugLog.Printf("Invalid %s value: %v", field, err) | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| for _, field := range opts.IntFields { | ||
| if err := preprocessIntFieldAsString(configData, field, log); err != nil { | ||
| log.Printf("Invalid %s value: %v", field, err) | ||
| if err := preprocessIntFieldAsString(configData, field, debugLog); err != nil { | ||
| debugLog.Printf("Invalid %s value: %v", field, err) | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| config := parseConfigScaffold(outputMap, configKey, log, onError) | ||
| config := parseConfigScaffold(outputMap, configKey, debugLog, onError) | ||
| if config == nil { | ||
| return nil | ||
| } | ||
|
|
||
There was a problem hiding this comment.
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_httpfollows the establishedpkg:filenameconvention and clearly identifies:clipackageDEBUG=cli:mcp_server_httpThis 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.