log 增加记录当前调用者的调用信息

This commit is contained in:
ziming 2025-06-18 10:36:13 +08:00
parent 5c2253cf92
commit 3a32575bab
1 changed files with 10 additions and 7 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/go-kratos/kratos/v2/log"
"github.com/redis/go-redis/v9"
"golang.org/x/sync/errgroup"
"runtime"
"time"
"voucher/internal/biz/bo"
"voucher/internal/biz/vo"
@ -161,16 +162,17 @@ func (v *VoucherBiz) ExecuteNotice(ctx context.Context, req *bo.FindInBatchesUse
func (v *VoucherBiz) notice(ctx context.Context, order *bo.OrderBo, notifyNum *int) (respErr error) {
// 批量通知不做数据存储,量会很大
defer func() {
if err := recover(); err != nil {
respErr = fmt.Errorf("panic:%v", err)
}
}()
if order == nil {
return fmt.Errorf("order is nil")
}
defer func() {
if err := recover(); err != nil {
_, file, line, _ := runtime.Caller(1) // 1 表示获取当前调用者的调用信息
respErr = fmt.Errorf("notice panic:%v, orderNo:%s, file:%s, line:%d", err, order.OrderNo, file, line)
}
}()
status, err := v.WechatCpnRepo.Query(ctx, order)
if err != nil {
return err
@ -210,7 +212,8 @@ func (v *VoucherBiz) request(ctx context.Context, order *bo.OrderBo, notify *bo.
defer func() {
if err := recover(); err != nil {
respErr = fmt.Errorf("panic:%v,orderNo:%s", err, order.OrderNo)
_, file, line, _ := runtime.Caller(1) // 1 表示获取当前调用者的调用信息
respErr = fmt.Errorf("panic:%v, orderNo:%s, file:%s, line:%d", err, order.OrderNo, file, line)
}
}()