mirror of
https://github.com/redis/go-redis.git
synced 2025-12-02 06:22:31 +03:00
chore: always display the last item in logger if the number of arguments is odd.
This commit is contained in:
@@ -18,10 +18,13 @@ func (l *legacyLoggerAdapter) structuredToPrintf(msg string, v ...any) (string,
|
||||
var args []any
|
||||
|
||||
for i := 0; i < len(v); i += 2 {
|
||||
format += " %v=%v"
|
||||
if i+1 >= len(v) {
|
||||
// Odd number of arguments, append a placeholder for the missing value
|
||||
// adapted from https://cs.opensource.google/go/go/+/master:src/log/slog/record.go;l=160-182;drc=8c41a482f9b7a101404cd0b417ac45abd441e598
|
||||
args = append(args, "!BADKEY", v[i])
|
||||
break
|
||||
}
|
||||
format += " %v=%v"
|
||||
args = append(args, v[i], v[i+1])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user