完善ErrorToEmail中间件
This commit is contained in:
@@ -2,12 +2,10 @@ package middleware
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"gin-vue-admin/global"
|
||||
"gin-vue-admin/model"
|
||||
"gin-vue-admin/model/request"
|
||||
"gin-vue-admin/service"
|
||||
"gin-vue-admin/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"io/ioutil"
|
||||
@@ -62,16 +60,6 @@ func OperationRecord() gin.HandlerFunc {
|
||||
record.Latency = latency
|
||||
record.Resp = writer.body.String()
|
||||
|
||||
if global.GVA_CONFIG.System.ErrorToEmail {
|
||||
if record.Status != 200 {
|
||||
subject := record.Ip+"调用了"+record.Path+"报错了"
|
||||
body, _ := json.Marshal(record)
|
||||
if err := utils.ErrorToEmail(subject, string(body)); err != nil{
|
||||
global.GVA_LOG.Error("ErrorToEmail Failed, err:", zap.Any("err", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := service.CreateSysOperationRecord(record); err != nil {
|
||||
global.GVA_LOG.Error("create operation record error:", zap.Any("err", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user