alarm_msg.go 779 B

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