[TASK] improve log message in webhooks
This commit is contained in:
parent
2155f245b7
commit
2d8949dc69
|
@ -43,10 +43,13 @@ func handler(_ http.Header, body interface{}) *log.Entry {
|
|||
}
|
||||
|
||||
entry := log.NewEntry(nil)
|
||||
entry = entry.WithField("hostname", request.Payload.VCSURL)
|
||||
entry = entry.WithFields(map[string]interface{}{
|
||||
"hostname": request.Payload.VCSURL,
|
||||
"url": request.Payload.BuildURL,
|
||||
})
|
||||
entry.Time = time.Now()
|
||||
entry.Level = HookstatusMap[request.Payload.Status]
|
||||
entry.Message = fmt.Sprintf("#%0.f (%0.fs): %s - %s", request.Payload.BuildNum, request.Payload.BuildTime/1000, request.Payload.Subject, request.Payload.BuildURL)
|
||||
entry.Message = fmt.Sprintf("#%0.f (%0.fs): %s", request.Payload.BuildNum, request.Payload.BuildTime/1000, request.Payload.Subject)
|
||||
return entry
|
||||
}
|
||||
|
||||
|
|
|
@ -51,14 +51,20 @@ func handler(_ http.Header, body interface{}) *log.Entry {
|
|||
}
|
||||
|
||||
entry := log.NewEntry(nil)
|
||||
entry = entry.WithField("hostname", request.RuleURL)
|
||||
entry = entry.WithFields(map[string]interface{}{
|
||||
"hostname": request.RuleURL,
|
||||
"ruleid": request.RuleID,
|
||||
"url": request.RuleURL,
|
||||
})
|
||||
if request.ImageURL != "" {
|
||||
entry = entry.WithField("imageurl", request.ImageURL)
|
||||
}
|
||||
entry.Time = time.Now()
|
||||
entry.Level = HookstateMap[request.State]
|
||||
if request.Message == "" {
|
||||
entry.Message = fmt.Sprintf("%s - %s: %s", request.Title, request.State, request.RuleURL)
|
||||
} else {
|
||||
entry.Message = fmt.Sprintf("%s - %s: %s %s", request.Title, request.State, request.Message, request.RuleURL)
|
||||
for _, e := range request.EvalMatches {
|
||||
entry = entry.WithField(e.Metric, e.Value)
|
||||
}
|
||||
entry.Message = fmt.Sprintf("%s: %s", request.Title, request.Message)
|
||||
return entry
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue