瀏覽代碼

Log failed tests

Brendan Abolivier 7 年之前
父節點
當前提交
0430839b01
簽署人: Brendan Abolivier <contact@brendanabolivier.com> GPG 金鑰 ID: 8EF1500759F70623
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7
    0
      src/metrics-alerting/alert/alert.go

+ 7
- 0
src/metrics-alerting/alert/alert.go 查看文件

6
 	"metrics-alerting/config"
6
 	"metrics-alerting/config"
7
 	"metrics-alerting/script_data"
7
 	"metrics-alerting/script_data"
8
 
8
 
9
+	"github.com/sirupsen/logrus"
9
 	"gopkg.in/gomail.v2"
10
 	"gopkg.in/gomail.v2"
10
 )
11
 )
11
 
12
 
20
 	labels map[string]string,
21
 	labels map[string]string,
21
 	data script_data.Data,
22
 	data script_data.Data,
22
 ) error {
23
 ) error {
24
+	alertLog := fmt.Sprintf("Test for script \"%s\" failed", script.Key)
25
+	if len(data.Key) > 0 {
26
+		alertLog = alertLog + fmt.Sprintf(" (data: %s=%s)", data.Key, data.Value)
27
+	}
28
+	logrus.Info(alertLog)
29
+
23
 	switch script.Action {
30
 	switch script.Action {
24
 	case "http":
31
 	case "http":
25
 		return a.alertHttp(script, result, labels, data)
32
 		return a.alertHttp(script, result, labels, data)