From 9cfbea1907cf8c640c639bc8a635b90866e13c24 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sun, 8 Dec 2024 13:53:27 +0800 Subject: [PATCH] refactor: log uixt action --- hrp/internal/version/VERSION | 2 +- hrp/pkg/uixt/action.go | 24 +++++++++--------------- hrp/pkg/uixt/ai_vedem.go | 1 + 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 0f09526c..bf86200e 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2412081242 +v5.0.0+2412081353 diff --git a/hrp/pkg/uixt/action.go b/hrp/pkg/uixt/action.go index ea539e7b..4fc0d418 100644 --- a/hrp/pkg/uixt/action.go +++ b/hrp/pkg/uixt/action.go @@ -7,6 +7,7 @@ import ( "time" "github.com/pkg/errors" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "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) { - log.Info(). - Str("method", string(action.Method)). - Interface("params", action.Params). - Msg("uixt action start") actionStartTime := time.Now() - defer func() { + var logger *zerolog.Event if err != nil { - log.Error().Err(err). - Str("method", string(action.Method)). - Interface("params", action.Params). - Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()). - Msg("uixt action end") + logger = log.Error().Bool("success", false).Err(err) } else { - log.Info(). - Str("method", string(action.Method)). - Interface("params", action.Params). - Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()). - Msg("uixt action end") + logger = log.Debug().Bool("success", true) } + 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 { diff --git a/hrp/pkg/uixt/ai_vedem.go b/hrp/pkg/uixt/ai_vedem.go index bb84847d..c82e8dc2 100644 --- a/hrp/pkg/uixt/ai_vedem.go +++ b/hrp/pkg/uixt/ai_vedem.go @@ -189,6 +189,7 @@ func (s *veDEMImageService) GetImage(imageBuf *bytes.Buffer, options ...ActionOp Int("code", imageResponse.Code). Str("message", imageResponse.Message). Msg("request veDEM OCR service failed") + return nil, errors.New(imageResponse.Message) } imageResult = &imageResponse.Result