alarm_msg.go 744 B

1234567891011121314151617181920212223242526272829
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_report/utils"
  5. "github.com/rdlucklib/rdluck_tools/http"
  6. )
  7. // SendAlarmMsg
  8. // projectName-项目名称
  9. // runMode-运行模式
  10. // msgBody-消息内容
  11. // level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
  12. func SendAlarmMsg(msgBody string, level int) {
  13. if utils.AlarmMsgUrl == "" {
  14. return
  15. }
  16. params := make(map[string]interface{})
  17. params["ProjectName"] = utils.APPNAME
  18. params["RunMode"] = utils.RunMode
  19. params["MsgBody"] = msgBody
  20. params["Level"] = level
  21. param, err := json.Marshal(params)
  22. if err != nil {
  23. utils.FileLog.Info("SendAlarmMsg json.Marshal Err:" + err.Error())
  24. return
  25. }
  26. http.Post(utils.AlarmMsgUrl, string(param))
  27. }