alarm_msg.go 763 B

123456789101112131415161718192021222324252627282930
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/http"
  5. "hongze/hongze_edb_lib/utils"
  6. )
  7. var (
  8. AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send"
  9. )
  10. // SendAlarmMsg
  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.APP_NAME_CN
  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(AlarmMsgUrl, string(param))
  27. }