feat: add log for time

This commit is contained in:
2025-12-23 22:32:29 +08:00
parent 28295f825b
commit 3a86f811d0
2 changed files with 10 additions and 1 deletions

3
.gitignore vendored
View File

@@ -7,4 +7,5 @@
texpixel
/vendor
dev_deploy.sh
dev_deploy.sh
speed_take.sh

View File

@@ -738,6 +738,10 @@ func (s *RecognitionService) processMathpixTask(ctx context.Context, taskID int6
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)
if err != nil {
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()
log.Info(ctx, "func", "processMathpixTask", "msg", "MathpixApi_End", "end_time", time.Now(), "duration", time.Since(startTime))
body := &bytes.Buffer{}
if _, err = body.ReadFrom(resp.Body); err != nil {
log.Error(ctx, "func", "processMathpixTask", "msg", "读取响应体失败", "error", err)
@@ -790,6 +796,8 @@ func (s *RecognitionService) processMathpixTask(ctx context.Context, taskID int6
return err
}
log.Info(ctx, "func", "processMathpixTask", "msg", "saveLog", "end_time", time.Now(), "duration", time.Since(startTime))
if result == nil {
// 创建新结果
err = resultDao.Create(dao.DB.WithContext(ctx), dao.RecognitionResult{