Files
rclone/cmd/serve/s3/logger.go
Nick Craig-Wood 1c3e432c3f box, serve s3: fix log messages with bad format strings
The box backend logged an int64 with %q which printed
%!q(int64=123) instead of the sequence ID.

serve s3 passed the message from gofakes3 as the format string, so
any % in it was interpreted as a formatting directive and the message
was mangled.
2026-09-20 14:23:50 +01:00

36 lines
583 B
Go

package s3
import (
"fmt"
"strings"
"github.com/rclone/gofakes3"
"github.com/rclone/rclone/fs"
)
// logger output formatted message
type logger struct{}
// print log message
func (l logger) Print(level gofakes3.LogLevel, v ...any) {
var b strings.Builder
for i := range v {
if i > 0 {
fmt.Fprintf(&b, " ")
}
fmt.Fprint(&b, v[i])
}
s := b.String()
switch level {
default:
fallthrough
case gofakes3.LogErr:
fs.Errorf("serve s3", "%s", s)
case gofakes3.LogWarn:
fs.Infof("serve s3", "%s", s)
case gofakes3.LogInfo:
fs.Debugf("serve s3", "%s", s)
}
}