Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions op5/scripts/send2jsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func main() {
} else {
panic(err)
}
logger = configureLogger()

errFromConf := readConfigurationFileFromJECConfig(configPath2)

Expand All @@ -55,6 +54,8 @@ func main() {
version := flag.String("v", "", "")
parseFlags()

logger = configureLogger()

printConfigToLog()

if *version != "" {
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down