Skip to content

Commit c3ad445

Browse files
anxkhnYuan325
andauthored
fix(tools/looker): log request/response traces at debug, not error (#3552)
## Description The `looker-get-dashboards` and `looker-generate-embed-url` tools log their routine "Making request" / "Got response" traces with `logger.ErrorContext`, while every other Looker tool logs the same kind of trace with `logger.DebugContext`. `StdLogger` routes `Error` to stderr, and these two tools emit the trace on every successful call, so normal, healthy operation produces ERROR-severity stderr lines: log spam, and false positives for anyone running log-based alerting. At the default log level the corrected `DebugContext` lines are suppressed entirely. This switches the four calls to `DebugContext` so they match the package convention and are debug-only. The `looker-get-dashboards` function already logs the response elements at debug one line later, so the edited lines now match their own surroundings. Message strings are unchanged; this is purely a severity fix. ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code -- not opened: this is a small, self-contained severity fix. Happy to file one if you'd prefer. - [x] Ensure the tests and linter pass -- `gofmt`, `go vet`, `go build ./...`, and `go test -race` on `internal/tools/looker/lookergetdashboards`, `internal/tools/looker/lookergenerateembedurl`, and `internal/log` all pass. - [x] Code coverage does not decrease -- no behavioral seam changed; the logging contract (Debug routes to the out stream and is suppressed at the default level; Error routes to the err stream) is already covered by `internal/log/log_test.go` (`TestStdLogger`). - [x] Appropriate docs were updated -- none needed. - [x] Make sure to add `!` if this involves a breaking change -- not a breaking change. Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
1 parent 3ebe500 commit c3ad445

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎internal/tools/looker/lookergenerateembedurl/lookergenerateembedurl.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par
141141
SessionLength: &sessionLength,
142142
ForceLogoutLogin: &forceLogoutLogin,
143143
}
144-
logger.ErrorContext(ctx, "Making request %v", req)
144+
logger.DebugContext(ctx, "Making request %v", req)
145145
resp, err := sdk.CreateEmbedUrlAsMe(req, nil)
146146
if err != nil {
147147
if strings.Contains(err.Error(), "status=401") {
148148
return nil, util.NewClientServerError("unauthorized error", http.StatusUnauthorized, err)
149149
}
150150
return nil, util.ProcessGeneralError(err)
151151
}
152-
logger.ErrorContext(ctx, "Got response %v", resp)
152+
logger.DebugContext(ctx, "Got response %v", resp)
153153

154154
return resp, nil
155155
}

‎internal/tools/looker/lookergetdashboards/lookergetdashboards.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ func (t Tool) Invoke(ctx context.Context, primitiveMgr tools.SourceProvider, par
137137
Limit: &limit,
138138
Offset: &offset,
139139
}
140-
logger.ErrorContext(ctx, "Making request %v", req)
140+
logger.DebugContext(ctx, "Making request %v", req)
141141
resp, err := sdk.SearchDashboards(req, source.LookerApiSettings())
142142
if err != nil {
143143
if strings.Contains(err.Error(), "status=401") {
144144
return nil, util.NewClientServerError("unauthorized error", http.StatusUnauthorized, err)
145145
}
146146
return nil, util.ProcessGeneralError(err)
147147
}
148-
logger.ErrorContext(ctx, "Got response %v", resp)
148+
logger.DebugContext(ctx, "Got response %v", resp)
149149
var data []any
150150
for _, v := range resp {
151151
logger.DebugContext(ctx, "Got response element of %v\n", v)

0 commit comments

Comments
 (0)