config: enable verbose logging by the --verbose argument - #5594

This commit is contained in:
Ivan Andreev 2021-10-02 12:50:11 +03:00
parent 8b8a943dd8
commit ffa1b1a258

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"net" "net"
"os" "os"
"strconv"
"strings" "strings"
"time" "time"
@ -179,6 +180,11 @@ func NewConfig() *ConfigInfo {
if arg == "--log-level=DEBUG" || (arg == "--log-level" && len(os.Args) > argIndex+1 && os.Args[argIndex+1] == "DEBUG") { if arg == "--log-level=DEBUG" || (arg == "--log-level" && len(os.Args) > argIndex+1 && os.Args[argIndex+1] == "DEBUG") {
c.LogLevel = LogLevelDebug c.LogLevel = LogLevelDebug
} }
if strings.HasPrefix(arg, "--verbose=") {
if level, err := strconv.Atoi(arg[10:]); err == nil && level >= 2 {
c.LogLevel = LogLevelDebug
}
}
} }
envValue, found := os.LookupEnv("RCLONE_LOG_LEVEL") envValue, found := os.LookupEnv("RCLONE_LOG_LEVEL")
if found && envValue == "DEBUG" { if found && envValue == "DEBUG" {