mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
feat: log step elapsed in seconds
This commit is contained in:
@@ -248,7 +248,7 @@ func (s *veDEMImageService) GetImage(imageBuf *bytes.Buffer) (
|
|||||||
log.Debug().
|
log.Debug().
|
||||||
Str("X-TT-LOGID", logID).
|
Str("X-TT-LOGID", logID).
|
||||||
Int("image_bytes", size).
|
Int("image_bytes", size).
|
||||||
Float64("elapsed_seconds", elapsed.Seconds()).
|
Float64("elapsed(s)", elapsed.Seconds()).
|
||||||
Msg("request OCR service success")
|
Msg("request OCR service success")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-8
@@ -539,8 +539,9 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
|
|||||||
parsedName = step.Name()
|
parsedName = step.Name()
|
||||||
}
|
}
|
||||||
stepName := convertString(parsedName)
|
stepName := convertString(parsedName)
|
||||||
log.Info().Str("step", stepName).
|
stepType := string(step.Type())
|
||||||
Str("type", string(step.Type())).Msg("run step start")
|
log.Info().Str("step", stepName).Str("type", stepType).Msg("run step start")
|
||||||
|
stepStartTime := time.Now()
|
||||||
|
|
||||||
// run times of step
|
// run times of step
|
||||||
loopTimes := step.Struct().Loops
|
loopTimes := step.Struct().Loops
|
||||||
@@ -563,10 +564,10 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// run step
|
// run step
|
||||||
stepStartTime := time.Now().Unix()
|
startTime := time.Now().Unix()
|
||||||
stepResult, err = step.Run(r)
|
stepResult, err = step.Run(r)
|
||||||
stepResult.Name = stepName + loopIndex
|
stepResult.Name = stepName + loopIndex
|
||||||
stepResult.StartTime = stepStartTime
|
stepResult.StartTime = startTime
|
||||||
|
|
||||||
r.updateSummary(stepResult)
|
r.updateSummary(stepResult)
|
||||||
}
|
}
|
||||||
@@ -576,19 +577,22 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
|
|||||||
r.sessionVariables[k] = v
|
r.sessionVariables[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stepElapsed := time.Since(stepStartTime).Seconds()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Info().Str("step", stepResult.Name).
|
log.Info().Str("step", stepName).
|
||||||
Str("type", string(stepResult.StepType)).
|
Str("type", stepType).
|
||||||
Bool("success", true).
|
Bool("success", true).
|
||||||
|
Float64("elapsed(s)", stepElapsed).
|
||||||
Interface("exportVars", stepResult.ExportVars).
|
Interface("exportVars", stepResult.ExportVars).
|
||||||
Msg("run step end")
|
Msg("run step end")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// failed
|
// failed
|
||||||
log.Error().Err(err).Str("step", stepResult.Name).
|
log.Error().Err(err).Str("step", stepName).
|
||||||
Str("type", string(stepResult.StepType)).
|
Str("type", stepType).
|
||||||
Bool("success", false).
|
Bool("success", false).
|
||||||
|
Float64("elapsed(s)", stepElapsed).
|
||||||
Msg("run step end")
|
Msg("run step end")
|
||||||
|
|
||||||
// interrupted or timeout, abort running
|
// interrupted or timeout, abort running
|
||||||
|
|||||||
Reference in New Issue
Block a user