diff --git a/cmd/charger.go b/cmd/charger.go index 9df2cbc00..d1991ee71 100644 --- a/cmd/charger.go +++ b/cmd/charger.go @@ -42,7 +42,7 @@ func runCharger(cmd *cobra.Command, args []string) { log.FATAL.Fatal(err) } - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) // setup environment if err := configureEnvironment(cmd, conf); err != nil { diff --git a/cmd/charger_ramp.go b/cmd/charger_ramp.go index bf9022290..40874c88c 100644 --- a/cmd/charger_ramp.go +++ b/cmd/charger_ramp.go @@ -76,7 +76,7 @@ func runChargerRamp(cmd *cobra.Command, args []string) { log.FATAL.Fatal(err) } - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) // setup environment if err := configureEnvironment(cmd, conf); err != nil { diff --git a/cmd/demo.yaml b/cmd/demo.yaml index 2a3690c04..bd6b07a69 100644 --- a/cmd/demo.yaml +++ b/cmd/demo.yaml @@ -1,7 +1,9 @@ network: port: 7070 -log: info +log: debug +levels: + mercedes: trace interval: 3s @@ -198,6 +200,15 @@ vehicles: title: grĂ¼ner Honda e capacity: 26 + - name: mercedes1 + type: mercedes + title: Mercedes + phases: 2 + vin: W1K2052131G009532 + clientId: 53c28422-25e4-47c2-9cf4-94a48065c5b3 + clientSecret: ePhxFTNyMbvslPqgoAfERHscIvpHZIaOfKPLjmEvQZDhSaocKAOiceLEVubDPyxP + identifiers: Jochen + site: title: Zuhause meters: @@ -211,7 +222,7 @@ loadpoints: mode: pv phases: 1 meter: meter_charger_1 - vehicle: vehicle_1 # default + # vehicle: vehicle_1 # default - title: Garage charger: charger_2 mode: "off" diff --git a/cmd/discuss.go b/cmd/discuss.go index c6f36ee45..8b3d07052 100644 --- a/cmd/discuss.go +++ b/cmd/discuss.go @@ -42,7 +42,7 @@ func runDiscuss(cmd *cobra.Command, args []string) { cfgErr := loadConfigFile(&conf) - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) file, pathErr := filepath.Abs(cfgFile) if pathErr != nil { diff --git a/cmd/dump.go b/cmd/dump.go index eda9f9e31..f5753fe9e 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -50,7 +50,7 @@ func runDump(cmd *cobra.Command, args []string) { // load config err := loadConfigFile(&conf) - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) // setup environment if err == nil { diff --git a/cmd/helper.go b/cmd/helper.go index 7cf2d4386..ee35bb7af 100644 --- a/cmd/helper.go +++ b/cmd/helper.go @@ -11,20 +11,8 @@ import ( "time" "github.com/evcc-io/evcc/cmd/shutdown" - "github.com/evcc-io/evcc/util" - "github.com/spf13/cobra" - "github.com/spf13/viper" ) -// setLogLevel sets log level from config overwritten by command line -// https://github.com/spf13/viper/issues/1444 -func setLogLevel(cmd *cobra.Command) { - if flag := cmd.Flags().Lookup("log"); viper.GetString("log") == "" || flag.Changed { - viper.Set("log", flag.Value.String()) - } - util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) -} - // unwrap converts a wrapped error into slice of strings func unwrap(err error) (res []string) { for err != nil { diff --git a/cmd/meter.go b/cmd/meter.go index 486197cf0..f48b38c8a 100644 --- a/cmd/meter.go +++ b/cmd/meter.go @@ -31,7 +31,7 @@ func runMeter(cmd *cobra.Command, args []string) { log.FATAL.Fatal(err) } - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) // setup environment if err := configureEnvironment(cmd, conf); err != nil { diff --git a/cmd/root.go b/cmd/root.go index 6dbf4df6d..dada7ac23 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -110,7 +110,7 @@ func runRoot(cmd *cobra.Command, args []string) { err = cfgErr } - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) // network config if viper.GetString("uri") != "" { diff --git a/cmd/token.go b/cmd/token.go index 36f4b10a4..97ffcd999 100644 --- a/cmd/token.go +++ b/cmd/token.go @@ -33,7 +33,7 @@ func runToken(cmd *cobra.Command, args []string) { log.FATAL.Fatal(err) } - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) var vehicleConf qualifiedConfig if len(conf.Vehicles) == 1 { diff --git a/cmd/vehicle.go b/cmd/vehicle.go index b9dfa8fd0..0c0f58631 100644 --- a/cmd/vehicle.go +++ b/cmd/vehicle.go @@ -34,7 +34,7 @@ func runVehicle(cmd *cobra.Command, args []string) { fatal(err) } - setLogLevel(cmd) + util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels")) // setup environment if err := configureEnvironment(cmd, conf); err != nil {