2019-07-15 22:16:02 +02:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-10-10 16:50:33 +02:00
|
|
|
"github.com/lbryio/lbry.go/v2/extras/util"
|
2019-07-15 22:16:02 +02:00
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SendErrorToSlack Sends an error message to the default channel and to the process log.
|
|
|
|
func SendErrorToSlack(format string, a ...interface{}) {
|
|
|
|
message := format
|
|
|
|
if len(a) > 0 {
|
|
|
|
message = fmt.Sprintf(format, a...)
|
|
|
|
}
|
|
|
|
log.Errorln(message)
|
2021-12-02 16:59:14 +01:00
|
|
|
log.SetLevel(log.InfoLevel) //I don't want to change the underlying lib so this will do...
|
2021-11-24 18:37:04 +01:00
|
|
|
err := util.SendToSlack(":sos: ```" + message + "```")
|
2021-12-02 16:59:14 +01:00
|
|
|
log.SetLevel(log.DebugLevel)
|
2019-07-15 22:16:02 +02:00
|
|
|
if err != nil {
|
|
|
|
log.Errorln(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SendInfoToSlack Sends an info message to the default channel and to the process log.
|
|
|
|
func SendInfoToSlack(format string, a ...interface{}) {
|
|
|
|
message := format
|
|
|
|
if len(a) > 0 {
|
|
|
|
message = fmt.Sprintf(format, a...)
|
|
|
|
}
|
|
|
|
log.Infoln(message)
|
2021-12-02 16:59:14 +01:00
|
|
|
log.SetLevel(log.InfoLevel) //I don't want to change the underlying lib so this will do...
|
2019-07-15 22:16:02 +02:00
|
|
|
err := util.SendToSlack(":information_source: " + message)
|
2021-12-02 16:59:14 +01:00
|
|
|
log.SetLevel(log.DebugLevel)
|
2019-07-15 22:16:02 +02:00
|
|
|
if err != nil {
|
|
|
|
log.Errorln(err)
|
|
|
|
}
|
|
|
|
}
|