alarm_msg.go 806 B

12345678910111213141516171819202122232425262728293031
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_bridge/global"
  5. "eta_gn/eta_bridge/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.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. global.FILE_LOG.Info(string(param))
  27. //_, _ = http.Post(AlarmMsgUrl, string(param))
  28. }