refactor: log uixt action

This commit is contained in:
lilong.129
2024-12-08 13:53:27 +08:00
parent b3db26f6f9
commit 9cfbea1907
3 changed files with 11 additions and 16 deletions
+1 -1
View File
@@ -1 +1 @@
v5.0.0+2412081242 v5.0.0+2412081353
+9 -15
View File
@@ -7,6 +7,7 @@ import (
"time" "time"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin" "github.com/httprunner/httprunner/v4/hrp/internal/builtin"
@@ -565,26 +566,19 @@ func (dExt *DriverExt) GenAbsScope(x1, y1, x2, y2 float64) AbsScope {
} }
func (dExt *DriverExt) DoAction(action MobileAction) (err error) { func (dExt *DriverExt) DoAction(action MobileAction) (err error) {
log.Info().
Str("method", string(action.Method)).
Interface("params", action.Params).
Msg("uixt action start")
actionStartTime := time.Now() actionStartTime := time.Now()
defer func() { defer func() {
var logger *zerolog.Event
if err != nil { if err != nil {
log.Error().Err(err). logger = log.Error().Bool("success", false).Err(err)
Str("method", string(action.Method)).
Interface("params", action.Params).
Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()).
Msg("uixt action end")
} else { } else {
log.Info(). logger = log.Debug().Bool("success", true)
Str("method", string(action.Method)).
Interface("params", action.Params).
Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()).
Msg("uixt action end")
} }
logger = logger.
Str("method", string(action.Method)).
Interface("params", action.Params).
Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds())
logger.Msg("exec uixt action")
}() }()
switch action.Method { switch action.Method {
+1
View File
@@ -189,6 +189,7 @@ func (s *veDEMImageService) GetImage(imageBuf *bytes.Buffer, options ...ActionOp
Int("code", imageResponse.Code). Int("code", imageResponse.Code).
Str("message", imageResponse.Message). Str("message", imageResponse.Message).
Msg("request veDEM OCR service failed") Msg("request veDEM OCR service failed")
return nil, errors.New(imageResponse.Message)
} }
imageResult = &imageResponse.Result imageResult = &imageResponse.Result