"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
Audit use of log.Print and change to Debug, Log, or ErrorLog as appropriate
Nick Craig-Wood67d0375b989a
diff --git a/fs/accounting.go b/fs/accounting.goindex f52ff1c8f..cfba8854d 100644--- a/fs/accounting.go+++ b/fs/accounting.go@@ -6,7 +6,6 @@ import ("bytes""fmt""io"- "log""sort""strings""sync"@@ -147,7 +146,7 @@ Elapsed time: %10v// Log outputs the StatsInfo to the logfunc (s *StatsInfo) Log() {- log.Printf("%v\n", s)+ Log(nil, "%v\n", s)}// Bytes updates the stats for bytes bytesdiff --git a/fs/config.go b/fs/config.goindex b9a960c50..3d9aea81b 100644--- a/fs/config.go+++ b/fs/config.go@@ -292,10 +292,10 @@ func configHome() string {if home != "" {return home}- log.Printf("Couldn't find home directory or read HOME environment variable.")- log.Printf("Defaulting to storing config in current directory.")- log.Printf("Use -config flag to workaround.")- log.Printf("Error was: %v", err)+ ErrorLog(nil, "Couldn't find home directory or read HOME environment variable.")+ ErrorLog(nil, "Defaulting to storing config in current directory.")+ ErrorLog(nil, "Use -config flag to workaround.")+ ErrorLog(nil, "Error was: %v", err)return ""}@@ -379,7 +379,7 @@ func LoadConfig() {func loadConfigFile() (*goconfig.ConfigFile, error) {b, err := ioutil.ReadFile(ConfigPath)if err != nil {- log.Printf("Failed to load config file \"%v\" - using defaults: %v", ConfigPath, err)+ Log(nil, "Failed to load config file \"%v\" - using defaults: %v", ConfigPath, err)return goconfig.LoadFromReader(&bytes.Buffer{})}@@ -450,7 +450,7 @@ func loadConfigFile() (*goconfig.ConfigFile, error) {}// Retry- log.Println("Couldn't decrypt configuration, most likely wrong password.")+ ErrorLog(nil, "Couldn't decrypt configuration, most likely wrong password.")configKey = nilenvpw = ""}@@ -509,7 +509,7 @@ func SaveConfig() {}err = os.Chmod(ConfigPath, 0600)if err != nil {- log.Printf("Failed to set permissions on config file: %v", err)+ ErrorLog(nil, "Failed to set permissions on config file: %v", err)}return}@@ -556,7 +556,7 @@ func SaveConfig() {err = os.Chmod(ConfigPath, 0600)if err != nil {- log.Printf("Failed to set permissions on config file: %v", err)+ ErrorLog(nil, "Failed to set permissions on config file: %v", err)}}@@ -712,7 +712,7 @@ func OkRemote(name string) bool {ConfigFile.DeleteSection(name)return truedefault:- log.Printf("Bad choice %d", i)+ ErrorLog(nil, "Bad choice %d", i)}return false}diff --git a/fs/loghttp.go b/fs/loghttp.goindex 81ed02061..c332c252f 100644--- a/fs/loghttp.go+++ b/fs/loghttp.go@@ -3,7 +3,6 @@package fsimport (- "log""net/http""net/http/httputil")@@ -35,7 +34,7 @@ func (t *LoggedTransport) CancelRequest(req *http.Request) {if wrapped, ok := t.wrapped.(interface {CancelRequest(*http.Request)}); ok {- log.Printf("CANCEL REQUEST %v", req)+ Debug(nil, "CANCEL REQUEST %v", req)wrapped.CancelRequest(req)}}@@ -43,19 +42,19 @@ func (t *LoggedTransport) CancelRequest(req *http.Request) {// RoundTrip implements the RoundTripper interface.func (t *LoggedTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {buf, _ := httputil.DumpRequestOut(req, t.logBody)- log.Println(separatorReq)- log.Println("HTTP REQUEST")- log.Println(string(buf))- log.Println(separatorReq)+ Debug(nil, "%s", separatorReq)+ Debug(nil, "%s", "HTTP REQUEST")+ Debug(nil, "%s", string(buf))+ Debug(nil, "%s", separatorReq)resp, err = t.wrapped.RoundTrip(req)- log.Println(separatorResp)- log.Println("HTTP RESPONSE")+ Debug(nil, "%s", separatorResp)+ Debug(nil, "%s", "HTTP RESPONSE")if err != nil {- log.Printf("Error: %v\n", err)+ Debug(nil, "Error: %v", err)} else {buf, _ = httputil.DumpResponse(resp, t.logBody)- log.Println(string(buf))+ Debug(nil, "%s", string(buf))}- log.Println(separatorResp)+ Debug(nil, "%s", separatorResp)return resp, err}diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.goindex 2164e912c..0192c08af 100644--- a/fstest/fstests/fstests.go+++ b/fstest/fstests/fstests.go@@ -9,7 +9,6 @@ import ("bytes""flag""io"- "log""os""path""runtime"@@ -69,7 +68,7 @@ func TestInit(t *testing.T) {if RemoteName == "" {RemoteName, err = fstest.LocalRemote()if err != nil {- log.Fatalf("Failed to create tmp dir: %v", err)+ t.Fatalf("Failed to create tmp dir: %v", err)}}subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(RemoteName)@@ -79,7 +78,7 @@ func TestInit(t *testing.T) {remote, err = fs.NewFs(subRemoteName)if err == fs.ErrorNotFoundInConfigFile {- log.Printf("Didn't find %q in config file - skipping tests", RemoteName)+ t.Logf("Didn't find %q in config file - skipping tests", RemoteName)return}if err != nil {@@ -668,7 +667,7 @@ func TestFinalise(t *testing.T) {// Remove temp directoryerr := os.Remove(RemoteName)if err != nil {- log.Printf("Failed to remove %q: %v\n", RemoteName, err)+ t.Logf("Failed to remove %q: %v\n", RemoteName, err)}}}diff --git a/rclone.go b/rclone.goindex 98d40bc19..abb62b976 100644--- a/rclone.go+++ b/rclone.go@@ -408,7 +408,7 @@ func main() {}_, err = f.Seek(0, os.SEEK_END)if err != nil {- log.Printf("Failed to seek log file to end: %v", err)+ fs.ErrorLog(nil, "Failed to seek log file to end: %v", err)}log.SetOutput(f)fs.DebugLogger.SetOutput(f)@@ -423,7 +423,7 @@ func main() {// Setup CPU profiling if desiredif *cpuProfile != "" {- log.Printf("Creating CPU profile %q\n", *cpuProfile)+ fs.Log(nil, "Creating CPU profile %q\n", *cpuProfile)f, err := os.Create(*cpuProfile)if err != nil {fs.Stats.Error()@@ -440,7 +440,7 @@ func main() {// Setup memory profiling if desiredif *memProfile != "" {defer func() {- log.Printf("Saving Memory profile %q\n", *memProfile)+ fs.Log(nil, "Saving Memory profile %q\n", *memProfile)f, err := os.Create(*memProfile)if err != nil {fs.Stats.Error()@@ -500,7 +500,7 @@ func main() {log.Fatalf("Failed to %s: %v", command.Name, err)}if !command.NoStats && (!fs.Config.Quiet || fs.Stats.Errored() || *statsInterval > 0) {- fmt.Fprintln(os.Stderr, fs.Stats)+ fs.Log(nil, "%s", fs.Stats)}if fs.Config.Verbose {fs.Debug(nil, "Go routines at exit %d\n", runtime.NumGoroutine())diff --git a/redirect_stderr.go b/redirect_stderr.goindex 6dbeb6014..37ff8d293 100644--- a/redirect_stderr.go+++ b/redirect_stderr.go@@ -5,11 +5,12 @@package mainimport (- "log""os"++ "github.com/ncw/rclone/fs")// redirectStderr to the file passed infunc redirectStderr(f *os.File) {- log.Printf("Can't redirect stderr to file")+ fs.ErrorLog(nil, "Can't redirect stderr to file")}diff --git a/yandex/yandex.go b/yandex/yandex.goindex 0eef428d2..7a61b927f 100644--- a/yandex/yandex.go+++ b/yandex/yandex.go@@ -16,6 +16,7 @@ import ("github.com/ncw/rclone/fs""github.com/ncw/rclone/oauthutil"yandex "github.com/ncw/rclone/yandex/api"+ "github.com/pkg/errors""golang.org/x/oauth2")@@ -553,8 +554,7 @@ func mkDirExecute(client *yandex.Client, path string) (int, string, error) {}if err != nil {// error creating directory- log.Printf("Failed to create folder: %v", err)- return statusCode, jsonErrorString, err+ return statusCode, jsonErrorString, errors.Wrap(err, "failed to create folder")}return 0, "", nil}