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.
This commit is contained in:
Nick Craig-Wood
2026-05-04 18:25:56 +01:00
parent ef26e6d26d
commit 3b2011c7a0

View File

@@ -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