Skip to content

Commit

Permalink
Minor change to slack notification: Format Date and Bold Message base…
Browse files Browse the repository at this point in the history
…d on logging level
  • Loading branch information
Manish committed Jul 12, 2022
1 parent 1d7adbe commit 292e099
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions common/log/slack_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,14 @@ func (sh *SlackHook) forward() {
if len(e.Data) > 0 { // If log was invoked WithFields, get the key value pairs
req = e.Data
}
req["Message"] = e.Message // Add the message passed to logging
// Add the message passed to logging
if e.Level == logrus.WarnLevel || e.Level == logrus.ErrorLevel || e.Level == logrus.FatalLevel || e.Level == logrus.PanicLevel {
req["Message"] = "*" + e.Message + "*"
} else {
req["Message"] = e.Message
}
req["Level"] = e.Level
req["Time"] = e.Time.UTC().String() // UTC Event log
req["Time"] = e.Time.UTC().Format("2006-01-02 15:04:05.000") // UTC Event log
if reqBytes, err := json.Marshal(req); err == nil && reqBytes != nil {
reqStr += string(reqBytes) + "\n"
} else {
Expand Down

0 comments on commit 292e099

Please sign in to comment.