mirror of
https://github.com/rclone/rclone
synced 2024-11-20 21:27:33 +01:00
fs: add log Printf, Fatalf and Panicf
This commit is contained in:
parent
4a54cc134f
commit
752809309d
23
fs/log.go
23
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
|
||||
|
Loading…
Reference in New Issue
Block a user