mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add quote method to config log messages
This commit is contained in:
parent
8d9e6fd273
commit
3c28137873
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user