add quote method to config log messages

This commit is contained in:
Bradley Cicenas
2017-02-18 14:30:54 +11:00
parent 8d9e6fd273
commit 3c28137873
2 changed files with 8 additions and 3 deletions

View File

@@ -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)