package am import ( "log" "os" "os/exec" "path/filepath" ) func run(cmd, name, text string) { c := exec.Command(cmd, name, text) c.Stderr = os.Stderr if err := c.Run(); err != nil { log.Printf("Failed to run command in shell `%s`: %v", cmd, err) } } func runLogAction(sourceName, text string) { log.Printf("[%s] %s", sourceName, text) dir, err := os.Getwd() if err != nil { log.Printf("Failed to get working directory: %v", err) return } action := filepath.Join(dir, "log-action") run(action, sourceName, text) } func runAlertAction(sourceName, text string) { log.Printf("[%s] ALERT %s", sourceName, text) dir, err := os.Getwd() if err != nil { log.Printf("Failed to get working directory: %v", err) return } action := filepath.Join(dir, "alert-action") run(action, sourceName, text) }