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

fs: add log Printf, Fatalf and Panicf

albertony752809309da9
diff --git a/fs/log.go b/fs/log.go
index 0b6512b2f..5b591b4c1 100644
--- a/fs/log.go
+++ b/fs/log.go
@@ -154,12 +154,35 @@ func LogLevelPrintf(level LogLevel, o interface{}, text string, args ...interfac
}
}
+// Panicf writes alert log output for this Object or Fs and calls panic().
+// It should always be seen by the user.
+func Panicf(o interface{}, text string, args ...interface{}) {
+ if GetConfig(context.TODO()).LogLevel >= LogLevelAlert {
+ LogPrintf(LogLevelAlert, o, text, args...)
+ }
+ panic(fmt.Sprintf(text, args...))
+}
+
+// Fatalf writes critical log output for this Object or Fs and calls os.Exit(1).
+// It should always be seen by the user.
+func Fatalf(o interface{}, text string, args ...interface{}) {
+ if GetConfig(context.TODO()).LogLevel >= LogLevelCritical {
+ LogPrintf(LogLevelCritical, o, text, args...)
+ }
+ os.Exit(1)
+}
+
// Errorf writes error log output for this Object or Fs. It
// should always be seen by the user.
func Errorf(o interface{}, text string, args ...interface{}) {
LogLevelPrintf(LogLevelError, o, text, args...)
}
+// Printf writes log output for this Object or Fs, same as Logf.
+func Printf(o interface{}, text string, args ...interface{}) {
+ LogLevelPrintf(LogLevelNotice, o, text, args...)
+}
+
// Logf writes log output for this Object or Fs. This should be
// considered to be Notice level logging. It is the default level.
// By default rclone should not log very much so only use this for