Commit 343ada04 authored by Sebastian Stark's avatar Sebastian Stark

move email formatting from main into own function

parent 24b036e5
package main
import (
"fmt"
"io/ioutil"
"log"
"os/exec"
)
func FailureMail(exitCode int, logBuffer *RingIO) {
mail := fmt.Sprintf("snaprd exited with return value %d.\nLatest log output:\n\n%s",
exitCode, logBuffer.GetAsText())
subject := fmt.Sprintf("snaprd failure (origin: %s)", config.Origin)
SendMail(config.Notify, subject, mail)
}
func NotifyMail(to, msg string) {
SendMail(to, "snaprd notice", msg)
}
......
......@@ -289,9 +289,7 @@ func main() {
rio := newRingIO(os.Stderr, 25, 100)
exitCode := mainExitCode(rio)
if exitCode != 0 && config.Notify != "" {
mail := fmt.Sprintf("snaprd exited with return value %d.\nLatest log output:\n\n%s",
exitCode, rio.GetAsText())
NotifyMail(config.Notify, mail)
FailureMail(exitCode, rio)
}
os.Exit(exitCode)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment