Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

protondrive: route library logging through rclone's logger

Nick Craig-Wood3b2011c7a09f
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