diff --git a/op5/scripts/send2jsm.go b/op5/scripts/send2jsm.go index 6211927..0cfaed8 100644 --- a/op5/scripts/send2jsm.go +++ b/op5/scripts/send2jsm.go @@ -44,7 +44,6 @@ func main() { } else { panic(err) } - logger = configureLogger() errFromConf := readConfigurationFileFromJECConfig(configPath2) @@ -55,6 +54,8 @@ func main() { version := flag.String("v", "", "") parseFlags() + logger = configureLogger() + printConfigToLog() if *version != "" { @@ -126,6 +127,9 @@ func readConfigurationFileFromJECConfig(filepath string) error { return err } + if data.LogPath != "" { + configParameters["logPath"] = data.LogPath + } if configParameters["apiKey"] == "" { configParameters["apiKey"] = data.ApiKey } @@ -141,16 +145,13 @@ func readConfigurationFileFromJECConfig(filepath string) error { type Configuration struct { ApiKey string `json:"apiKey"` BaseUrl string `json:"baseUrl"` + LogPath string `json:"logPath"` } func configureLogger() log.Logger { level := configParameters["nagios2jsm.logger"] var logFilePath = parameters["logPath"] - if len(logFilePath) == 0 { - logFilePath = "/var/log/jec/send2jsm.log" - } - var tmpLogger log.Logger file, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)