From f574e3395ca976814f57fadb95657df4c47d65c6 Mon Sep 17 00:00:00 2001 From: iTrooz Date: Mon, 6 Oct 2025 16:17:21 +0200 Subject: [PATCH] serve s3: fix log output to remove the EXTRA messages As shown in https://github.com/rclone/gofakes3/blob/81e56a30c86f942861f105439339812439b53415/log.go#L74 it seems like the wanted behaviour for merging arguments is the one of PrintLn, which is "put a space between each arg" --- cmd/serve/s3/logger.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cmd/serve/s3/logger.go b/cmd/serve/s3/logger.go index d99e27df7..cb0337f95 100644 --- a/cmd/serve/s3/logger.go +++ b/cmd/serve/s3/logger.go @@ -2,6 +2,7 @@ package s3 import ( "fmt" + "strings" "github.com/rclone/gofakes3" "github.com/rclone/rclone/fs" @@ -12,25 +13,23 @@ type logger struct{} // print log message func (l logger) Print(level gofakes3.LogLevel, v ...any) { - var s string - if len(v) == 0 { - s = "" - } else { - var ok bool - s, ok = v[0].(string) - if !ok { - s = fmt.Sprint(v[0]) + var b strings.Builder + for i := range v { + if i > 0 { + fmt.Fprintf(&b, " ") } - v = v[1:] + fmt.Fprint(&b, v[i]) } + s := b.String() + switch level { default: fallthrough case gofakes3.LogErr: - fs.Errorf("serve s3", s, v...) + fs.Errorf("serve s3", s) case gofakes3.LogWarn: - fs.Infof("serve s3", s, v...) + fs.Infof("serve s3", s) case gofakes3.LogInfo: - fs.Debugf("serve s3", s, v...) + fs.Debugf("serve s3", s) } }