feat: add log for time
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ texpixel
|
|||||||
/vendor
|
/vendor
|
||||||
|
|
||||||
dev_deploy.sh
|
dev_deploy.sh
|
||||||
|
speed_take.sh
|
||||||
@@ -738,6 +738,10 @@ func (s *RecognitionService) processMathpixTask(ctx context.Context, taskID int6
|
|||||||
|
|
||||||
endpoint := "https://api.mathpix.com/v3/text"
|
endpoint := "https://api.mathpix.com/v3/text"
|
||||||
|
|
||||||
|
startTime := time.Now()
|
||||||
|
|
||||||
|
log.Info(ctx, "func", "processMathpixTask", "msg", "MathpixApi_Start", "start_time", startTime)
|
||||||
|
|
||||||
resp, err := s.httpClient.RequestWithRetry(ctx, http.MethodPost, endpoint, bytes.NewReader(jsonData), headers)
|
resp, err := s.httpClient.RequestWithRetry(ctx, http.MethodPost, endpoint, bytes.NewReader(jsonData), headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "func", "processMathpixTask", "msg", "Mathpix API 请求失败", "error", err)
|
log.Error(ctx, "func", "processMathpixTask", "msg", "Mathpix API 请求失败", "error", err)
|
||||||
@@ -745,6 +749,8 @@ func (s *RecognitionService) processMathpixTask(ctx context.Context, taskID int6
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
log.Info(ctx, "func", "processMathpixTask", "msg", "MathpixApi_End", "end_time", time.Now(), "duration", time.Since(startTime))
|
||||||
|
|
||||||
body := &bytes.Buffer{}
|
body := &bytes.Buffer{}
|
||||||
if _, err = body.ReadFrom(resp.Body); err != nil {
|
if _, err = body.ReadFrom(resp.Body); err != nil {
|
||||||
log.Error(ctx, "func", "processMathpixTask", "msg", "读取响应体失败", "error", err)
|
log.Error(ctx, "func", "processMathpixTask", "msg", "读取响应体失败", "error", err)
|
||||||
@@ -790,6 +796,8 @@ func (s *RecognitionService) processMathpixTask(ctx context.Context, taskID int6
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info(ctx, "func", "processMathpixTask", "msg", "saveLog", "end_time", time.Now(), "duration", time.Since(startTime))
|
||||||
|
|
||||||
if result == nil {
|
if result == nil {
|
||||||
// 创建新结果
|
// 创建新结果
|
||||||
err = resultDao.Create(dao.DB.WithContext(ctx), dao.RecognitionResult{
|
err = resultDao.Create(dao.DB.WithContext(ctx), dao.RecognitionResult{
|
||||||
|
|||||||
Reference in New Issue
Block a user