From 3b2011c7a09fc32d8a62036891bbd47a36175e4d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 4 May 2026 18:25:56 +0100 Subject: [PATCH] protondrive: route library logging through rclone's logger Previously all log output produced by Proton-API-Bridge (stdlib log) and go-proton-api (logrus + resty's logger) bypassed rclone's logging: it ignored -v / -vv levels and didn't reach --log-file. Add a small adapter implementing the resty.Logger / bridge Logger shape that calls fs.Errorf / fs.Logf / fs.Debugf, and pass it via the new Config.Logger hook. The bridge in turn forwards the same value to go-proton-api's WithLogger option, so HTTP-layer warnings and the formerly-hardcoded logrus warnings inside go-proton-api also surface through rclone's log levels. --- backend/protondrive/protondrive.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/protondrive/protondrive.go b/backend/protondrive/protondrive.go index 0211696ee..af6485ee3 100644 --- a/backend/protondrive/protondrive.go +++ b/backend/protondrive/protondrive.go @@ -421,6 +421,16 @@ func isDecimalString(value string) bool { return true } +// protonLogger adapts rclone's fs.Debugf/Logf/Errorf into the +// resty.Logger / common.Logger shape expected by Proton-API-Bridge and +// go-proton-api so that library output participates in -v / -vv levels +// and is captured by --log-file. +type protonLogger struct{ f *Fs } + +func (l protonLogger) Errorf(format string, v ...interface{}) { fs.Errorf(l.f, format, v...) } +func (l protonLogger) Warnf(format string, v ...interface{}) { fs.Logf(l.f, format, v...) } +func (l protonLogger) Debugf(format string, v ...interface{}) { fs.Debugf(l.f, format, v...) } + func newProtonDrive(ctx context.Context, f *Fs, opt *Options, m configmap.Mapper) (*protonDriveAPI.ProtonDrive, error) { config := protonDriveAPI.NewDefaultConfig() config.AppVersion = opt.AppVersion @@ -434,6 +444,10 @@ func newProtonDrive(ctx context.Context, f *Fs, opt *Options, m configmap.Mapper // --ca-cert and --header all take effect against Proton Drive. config.Transport = fshttp.NewTransport(ctx) + // Route bridge and go-proton-api log output through rclone's + // logging system so it honours -v / -vv and --log-file. + config.Logger = protonLogger{f: f} + config.ReplaceExistingDraft = opt.ReplaceExistingDraft config.EnableCaching = opt.EnableCaching