Skip to content

Commit

Permalink
fix: default logger wasn't spreading varargs properly (#268)
Browse files Browse the repository at this point in the history
The default logger was calling Printf with its varargs array
without spreading it back out, meaning that the whole array
would get formatted into the first %s.  This spreads the varargs
back out properly.
  • Loading branch information
cprice404 authored Mar 10, 2023
1 parent 0a52f1b commit c4bcc3c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ func (l *DefaultMomentoLogger) Error(message string, args ...string) {
}

func momentoLog(level LogLevel, loggerName string, message string, args ...string) {
finalMessage := fmt.Sprintf(message, args)
anyArgs := make([]any, len(args))
for i, v := range args {
anyArgs[i] = v
}
finalMessage := fmt.Sprintf(message, anyArgs...)
log.Printf("[%s] %d (%s): %s\n", time.RFC3339, level, loggerName, finalMessage)
}

Expand Down

0 comments on commit c4bcc3c

Please sign in to comment.