mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 01:44:41 +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
|
// Errorf writes error log output for this Object or Fs. It
|
||||||
// should always be seen by the user.
|
// should always be seen by the user.
|
||||||
func Errorf(o interface{}, text string, args ...interface{}) {
|
func Errorf(o interface{}, text string, args ...interface{}) {
|
||||||
LogLevelPrintf(LogLevelError, o, text, args...)
|
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
|
// Logf writes log output for this Object or Fs. This should be
|
||||||
// considered to be Notice level logging. It is the default level.
|
// considered to be Notice level logging. It is the default level.
|
||||||
// By default rclone should not log very much so only use this for
|
// By default rclone should not log very much so only use this for
|
||||||
|
Loading…
Reference in New Issue
Block a user