Skip to content

Commit 451ff26

Browse files
committed
Another attempt at satisfying the analyzer
1 parent 5faced8 commit 451ff26

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

sql/analyzer/analyzer.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,23 @@ func NewDefault(provider sql.DatabaseProvider) *Analyzer {
291291
// Log prints an INFO message to stdout with the given message and args
292292
// if the analyzer is in debug mode.
293293
func (a *Analyzer) Log(msg string, args ...interface{}) {
294-
if a != nil && a.Debug {
295-
if len(a.contextStack) > 0 {
296-
ctx := strings.Join(a.contextStack, "/")
297-
sanitizedArgs := sanitizeArguments(args)
298-
log.Infof("%s: "+msg, append([]interface{}{ctx}, sanitizedArgs...)...)
299-
} else {
300-
sanitizedArgs := sanitizeArguments(args)
301-
log.Infof(msg, sanitizedArgs...)
294+
if a == nil || !a.Debug {
295+
return
296+
}
297+
298+
sanitizedArgs := sanitizeArguments(args)
299+
300+
if len(a.contextStack) > 0 {
301+
ctx := strings.Join(a.contextStack, "/")
302+
// Create a new slice for the final arguments to avoid direct append with variadic expansion
303+
finalArgs := make([]interface{}, len(sanitizedArgs)+1)
304+
finalArgs[0] = ctx
305+
for i, arg := range sanitizedArgs {
306+
finalArgs[i+1] = arg
302307
}
308+
log.Infof("%s: "+msg, finalArgs...)
309+
} else {
310+
log.Infof(msg, sanitizedArgs...)
303311
}
304312
}
305313

0 commit comments

Comments
 (0)