修改了log

This commit is contained in:
wucongxing8150 2024-05-29 15:45:57 +08:00
parent 032730ba3e
commit f5694cb227
2 changed files with 21 additions and 7 deletions

View File

@ -257,12 +257,13 @@ func (r *CouponService) ReceiveCoupon(req requestsV1.ReceiveCoupon) (g *dtoV1.Re
return nil, err
}
// 发送通知
res, _ := service.PatientDistributeCoupon(coupon.CouponName, user.UserId)
if !res {
utils.LogJsonInfo("优惠卷通知发送失败")
}
go func() {
// 发送通知
res, _ := service.PatientDistributeCoupon(coupon.CouponName, user.UserId)
if !res {
utils.LogJsonError("优惠卷通知发送失败")
}
}()
}
}

View File

@ -15,9 +15,22 @@ func LogJsonInfo(v interface{}) {
}
jsonString := string(jsonData)
fmt.Println(jsonString)
global.Logger.WithFields(logrus.Fields{
"data": jsonString,
}).Info("info")
}
func LogJsonError(v interface{}) {
jsonData, err := json.Marshal(v)
if err != nil {
fmt.Println("Error marshaling struct to JSON:", err)
return
}
jsonString := string(jsonData)
global.Logger.WithFields(logrus.Fields{
"data": jsonString,
}).Info("error")
}