diff --git a/config/main.go b/config/main.go index 377b83d..d5b0d4a 100644 --- a/config/main.go +++ b/config/main.go @@ -1,6 +1,7 @@ package config import ( + "fmt" "os" "github.com/bcicen/ctop/logging" @@ -15,15 +16,19 @@ var ( func Init() { for _, p := range params { GlobalParams = append(GlobalParams, p) - log.Infof("loaded config param: \"%s\": \"%s\"", p.Key, p.Val) + log.Infof("loaded config param: %s: %s", quote(p.Key), quote(p.Val)) } for _, s := range switches { GlobalSwitches = append(GlobalSwitches, s) - log.Infof("loaded config switch: \"%s\": %t", s.Key, s.Val) + log.Infof("loaded config switch: %s: %t", quote(s.Key), s.Val) } } +func quote(s string) string { + return fmt.Sprintf("\"%s\"", s) +} + // Return env var value if set, else return defaultVal func getEnv(key, defaultVal string) string { val := os.Getenv(key) diff --git a/config/param.go b/config/param.go index a1d0584..950efa2 100644 --- a/config/param.go +++ b/config/param.go @@ -43,7 +43,7 @@ func GetVal(k string) string { // Set param value func Update(k, v string) { p := Get(k) - log.Noticef("config change: %s: %s -> %s", k, p.Val, v) + log.Noticef("config change: %s: %s -> %s", k, quote(p.Val), quote(v)) p.Val = v // log.Errorf("ignoring update for non-existant parameter: %s", k) }