From 61a39d44edfb490c57fb85c90ba761fa02070302 Mon Sep 17 00:00:00 2001 From: Elliot Jenkins Date: Tue, 16 Sep 2025 08:01:18 +0000 Subject: [PATCH 1/2] fix op5 logging 1) fix reading path from config file 2) fix override log file path from args 3) remove fallback to /var/log/jec/send2jsm.log --- op5/scripts/send2jsm.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/op5/scripts/send2jsm.go b/op5/scripts/send2jsm.go index 6211927..d278c24 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,7 +54,9 @@ func main() { version := flag.String("v", "", "") parseFlags() - printConfigToLog() + logger = configureLogger() + + printConfigToLog() if *version != "" { fmt.Println("JSM - OP5 1.0") @@ -126,6 +127,10 @@ func readConfigurationFileFromJECConfig(filepath string) error { return err } + if data.LogPath != "" { + configParameters["logPath"] = data.LogPath + } + if configParameters["apiKey"] == "" { configParameters["apiKey"] = data.ApiKey } @@ -141,16 +146,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) From b445ba76b62937c7acf041bfe9ac43809039f643 Mon Sep 17 00:00:00 2001 From: Elliot Jenkins Date: Tue, 16 Sep 2025 08:23:37 +0000 Subject: [PATCH 2/2] fix whitespace --- op5/scripts/send2jsm.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/op5/scripts/send2jsm.go b/op5/scripts/send2jsm.go index d278c24..0cfaed8 100644 --- a/op5/scripts/send2jsm.go +++ b/op5/scripts/send2jsm.go @@ -54,9 +54,9 @@ func main() { version := flag.String("v", "", "") parseFlags() - logger = configureLogger() + logger = configureLogger() - printConfigToLog() + printConfigToLog() if *version != "" { fmt.Println("JSM - OP5 1.0") @@ -127,10 +127,9 @@ func readConfigurationFileFromJECConfig(filepath string) error { return err } - if data.LogPath != "" { - configParameters["logPath"] = data.LogPath - } - + if data.LogPath != "" { + configParameters["logPath"] = data.LogPath + } if configParameters["apiKey"] == "" { configParameters["apiKey"] = data.ApiKey } @@ -146,7 +145,7 @@ func readConfigurationFileFromJECConfig(filepath string) error { type Configuration struct { ApiKey string `json:"apiKey"` BaseUrl string `json:"baseUrl"` - LogPath string `json:"logPath"` + LogPath string `json:"logPath"` } func configureLogger() log.Logger {