Use ccLogger anywhere

This commit is contained in:
Thomas Roehl
2022-01-25 17:43:10 +01:00
parent b4fde31626
commit 2925ad9f40
8 changed files with 85 additions and 112 deletions

View File

@@ -100,6 +100,7 @@ func ReadCli() map[string]string {
logfile := flag.String("log", "stderr", "Path for logfile")
pidfile := flag.String("pidfile", "/var/run/cc-metric-collector.pid", "Path for PID file")
once := flag.Bool("once", false, "Run all collectors only once")
debug := flag.Bool("debug", false, "Activate debug output")
flag.Parse()
m = make(map[string]string)
m["configfile"] = *cfg
@@ -110,6 +111,12 @@ func ReadCli() map[string]string {
} else {
m["once"] = "false"
}
if *debug {
m["debug"] = "true"
cclog.SetDebug()
} else {
m["debug"] = "false"
}
return m
}
@@ -219,6 +226,10 @@ func mainFunc() int {
// Drop domain part of host name
rcfg.Hostname = strings.SplitN(rcfg.Hostname, `.`, 2)[0]
// err = CreatePidfile(rcfg.CliArgs["pidfile"])
if rcfg.CliArgs["logfile"] != "stderr" {
cclog.SetOutput(rcfg.CliArgs["logfile"])
}
// err = SetLogging(rcfg.CliArgs["logfile"])
// if err != nil {
// log.Print("Error setting up logging system to ", rcfg.CliArgs["logfile"], " on ", rcfg.Hostname)