Skip to content

Commit 3cff915

Browse files
authored
fix: debug logging statements (googleapis#1828)
## Description The debug context logger does not take in value placeholders. The statements must be first converted to a string. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here>
1 parent 5a6db19 commit 3cff915

13 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
309309
if err != nil {
310310
return nil, fmt.Errorf("error getting logger: %s", err)
311311
}
312-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, sql)
312+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, sql))
313313

314314
// This block handles SELECT statements, which return a row set.
315315
// We iterate through the results, convert each row into a map of

‎internal/tools/bigquery/bigqueryforecast/bigqueryforecast.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
294294
if err != nil {
295295
return nil, fmt.Errorf("error getting logger: %s", err)
296296
}
297-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, sql)
297+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, sql))
298298

299299
// This block handles SELECT statements, which return a row set.
300300
// We iterate through the results, convert each row into a map of

‎internal/tools/firebird/firebirdexecutesql/firebirdexecutesql.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (t *Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
116116
if err != nil {
117117
return nil, fmt.Errorf("error getting logger: %s", err)
118118
}
119-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, sql)
119+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, sql))
120120

121121
rows, err := t.Db.QueryContext(ctx, sql)
122122
if err != nil {

‎internal/tools/mongodb/mongodbfind/mongodbfind.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ func getOptions(ctx context.Context, sortParameters tools.Parameters, projectPay
178178
}
179179

180180
opts = opts.SetProjection(projection)
181-
logger.DebugContext(ctx, "Projection is set to %v", projection)
181+
logger.DebugContext(ctx, fmt.Sprintf("Projection is set to %v", projection))
182182
}
183183

184184
if limit > 0 {
185185
opts = opts.SetLimit(limit)
186-
logger.DebugContext(ctx, "Limit is being set to %d", limit)
186+
logger.DebugContext(ctx, fmt.Sprintf("Limit is being set to %d", limit))
187187
}
188188
return opts, nil
189189
}

‎internal/tools/mssql/mssqlexecutesql/mssqlexecutesql.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
125125
if err != nil {
126126
return nil, fmt.Errorf("error getting logger: %s", err)
127127
}
128-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, sql)
128+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, sql))
129129

130130
results, err := t.Pool.QueryContext(ctx, sql)
131131
if err != nil {

‎internal/tools/mysql/mysqlexecutesql/mysqlexecutesql.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
126126
if err != nil {
127127
return nil, fmt.Errorf("error getting logger: %s", err)
128128
}
129-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, sql)
129+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, sql))
130130

131131
results, err := t.Pool.QueryContext(ctx, sql)
132132
if err != nil {

‎internal/tools/mysql/mysqllistactivequeries/mysqllistactivequeries.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
206206
if err != nil {
207207
return nil, fmt.Errorf("error getting logger: %s", err)
208208
}
209-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, t.statement)
209+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, t.statement))
210210

211211
results, err := t.Pool.QueryContext(ctx, t.statement, duration, duration, limit)
212212
if err != nil {

‎internal/tools/mysql/mysqllisttablefragmentation/mysqllisttablefragmentation.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
163163
if err != nil {
164164
return nil, fmt.Errorf("error getting logger: %s", err)
165165
}
166-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, listTableFragmentationStatement)
166+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, listTableFragmentationStatement))
167167

168168
results, err := t.Pool.QueryContext(ctx, listTableFragmentationStatement, table_schema, table_schema, table_name, table_name, data_free_threshold_bytes, limit)
169169
if err != nil {

‎internal/tools/mysql/mysqllisttablesmissinguniqueindexes/mysqllisttablesmissinguniqueindexes.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
154154
if err != nil {
155155
return nil, fmt.Errorf("error getting logger: %s", err)
156156
}
157-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, listTablesMissingUniqueIndexesStatement)
157+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, listTablesMissingUniqueIndexesStatement))
158158

159159
results, err := t.Pool.QueryContext(ctx, listTablesMissingUniqueIndexesStatement, table_schema, table_schema, limit)
160160
if err != nil {

‎internal/tools/oracle/oracleexecutesql/oracleexecutesql.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
113113
if err != nil {
114114
return nil, fmt.Errorf("error getting logger: %s", err)
115115
}
116-
logger.DebugContext(ctx, "executing `%s` tool query: %s", kind, sqlParam)
116+
logger.DebugContext(ctx, fmt.Sprintf("executing `%s` tool query: %s", kind, sqlParam))
117117

118118
results, err := t.Pool.QueryContext(ctx, sqlParam)
119119
if err != nil {

0 commit comments

Comments
 (0)