mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
Redo log level flags
* -vv or --log-level DEBUG * -v or --log-level INFO * --log-level NOTICE (default) * -q --log-level ERROR Replace Config.Verbose and Config.Quiet with Config.LogLevel Fixes #739 Fixes #1108 Fixes #1000
This commit is contained in:
37
fs/log.go
37
fs/log.go
@@ -11,9 +11,11 @@ import (
|
||||
// LogLevel describes rclone's logs. These are a subset of the syslog log levels.
|
||||
type LogLevel byte
|
||||
|
||||
//go:generate stringer -type=LogLevel
|
||||
|
||||
// Log levels - a subset of the syslog logs
|
||||
const (
|
||||
LogLevelEmergency = iota
|
||||
LogLevelEmergency LogLevel = iota
|
||||
LogLevelAlert
|
||||
LogLevelCritical
|
||||
LogLevelError // Error - can't be suppressed
|
||||
@@ -38,30 +40,37 @@ func makeLog(o interface{}, text string, args ...interface{}) string {
|
||||
}
|
||||
|
||||
// Errorf writes error log output for this Object or Fs. It
|
||||
// unconditionally logs a message regardless of Config.Quiet or
|
||||
// Config.Verbose.
|
||||
// unconditionally logs a message regardless of Config.LogLevel
|
||||
func Errorf(o interface{}, text string, args ...interface{}) {
|
||||
log.Print(makeLog(o, text, args...))
|
||||
}
|
||||
|
||||
// Logf writes log output for this Object or Fs. This should be
|
||||
// considered to be Info level logging.
|
||||
func Logf(o interface{}, text string, args ...interface{}) {
|
||||
if !Config.Quiet {
|
||||
if Config.LogLevel >= LogLevelError {
|
||||
log.Print(makeLog(o, text, args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Infof writes info on transfers for this Object or Fs
|
||||
// Logf writes log output for this Object or Fs. This should be
|
||||
// considered to be Info level logging. It is the default level. By
|
||||
// default rclone should not log very much so only use this for
|
||||
// important things the user should see. The user can filter these
|
||||
// out with the -q flag.
|
||||
func Logf(o interface{}, text string, args ...interface{}) {
|
||||
if Config.LogLevel >= LogLevelNotice {
|
||||
log.Print(makeLog(o, text, args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Infof writes info on transfers for this Object or Fs. Use this
|
||||
// level for logging transfers, deletions and things which should
|
||||
// appear with the -v flag.
|
||||
func Infof(o interface{}, text string, args ...interface{}) {
|
||||
if Config.Verbose {
|
||||
if Config.LogLevel >= LogLevelInfo {
|
||||
DebugLogger.Print(makeLog(o, text, args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Debugf writes debugging output for this Object or Fs
|
||||
// Debugf writes debugging output for this Object or Fs. Use this for
|
||||
// debug only. The user must have to specify -vv to see this.
|
||||
func Debugf(o interface{}, text string, args ...interface{}) {
|
||||
if Config.Verbose {
|
||||
if Config.LogLevel >= LogLevelDebug {
|
||||
DebugLogger.Print(makeLog(o, text, args...))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user