Add per area log levels at command line (#4813)

This commit is contained in:
andig 2022-10-14 17:51:53 +02:00 • committed by GitHub
parent e5a65bc1b9
commit bafb3a7e79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 27 additions and 69 deletions

View file

@ -81,6 +81,10 @@ func initConfig() {
}
viper.AutomaticEnv() // read in environment variables that match
// print version
util.LogLevel("info", nil)
log.INFO.Printf("evcc %s", server.FormattedVersion())
}
// Execute adds all child commands to the root command and sets flags appropriately.
@ -98,9 +102,6 @@ func publish(key string, val any) {
}
func runRoot(cmd *cobra.Command, args []string) {
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
log.INFO.Printf("evcc %s", server.FormattedVersion())
// load config and re-configure logging after reading config file
var err error
if cfgErr := loadConfigFile(&conf); errors.As(cfgErr, &viper.ConfigFileNotFoundError{}) {
@ -110,8 +111,6 @@ func runRoot(cmd *cobra.Command, args []string) {
err = cfgErr
}
util.LogLevel(viper.GetString("log"), viper.GetStringMapString("levels"))
// network config
if viper.GetString("uri") != "" {
log.WARN.Println("`uri` is deprecated and will be ignored. Use `network` instead.")