Skip to content

Commit

Permalink
log to either syslog or stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
frese committed Aug 14, 2020
1 parent 9a7b307 commit 6854ca5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ func filterInit(filtertype string, cfg *ini.File) []Filter {
return list
}

func logInit() {
// setup logger to use syslog
logwriter, e := syslog.New(syslog.LOG_NOTICE, "pagerdutynotifier")
if e == nil {
log.SetOutput(logwriter)
func logInit(out string) {
switch out {
case "syslog":
// setup logger to use syslog
logwriter, e := syslog.New(syslog.LOG_NOTICE, "pagerdutynotifier")
if e == nil {
log.SetOutput(logwriter)
}
case "stdout":
log.SetOutput(os.Stdout)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ func main() {
// is approx 3 year old, written for an older OS version ?
runtime.LockOSThread()

logInit() // Initialize logger
appInit() // setup application tray menu, icons etc
cfg := cfgInit() // read configuration file
pdInit(cfg) // Initialize Pagerduty stuff
logInit("syslog") // Initialize logger
appInit() // setup application tray menu, icons etc
cfg := cfgInit() // read configuration file
pdInit(cfg) // Initialize Pagerduty stuff

interval, err := cfg.Section("pagerduty").Key("interval").Int()
if err != nil {
Expand Down

0 comments on commit 6854ca5

Please sign in to comment.