From 08399ef0eed123dda5f189fcd2c19cb925693f1c Mon Sep 17 00:00:00 2001 From: agrasthn <140591594+agrasth@users.noreply.github.com> Date: Thu, 29 May 2025 00:48:52 +0530 Subject: [PATCH] Yarn - Rewording log messages --- utils/retryexecutor.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/utils/retryexecutor.go b/utils/retryexecutor.go index bad3dc16e..1f37d4eaf 100644 --- a/utils/retryexecutor.go +++ b/utils/retryexecutor.go @@ -4,9 +4,10 @@ import ( "context" "errors" "fmt" - "github.com/jfrog/jfrog-client-go/utils/errorutils" "time" + "github.com/jfrog/jfrog-client-go/utils/errorutils" + "github.com/jfrog/jfrog-client-go/utils/log" ) @@ -81,18 +82,33 @@ func (runner *RetryExecutor) getTimeoutErrorMsg() string { } func (runner *RetryExecutor) LogRetry(attemptNumber int, err error) { - message := fmt.Sprintf("%s(Attempt %v)", runner.LogMsgPrefix, attemptNumber+1) + var message string + if attemptNumber == 0 { + message = fmt.Sprintf("%s[Initial attempt]", runner.LogMsgPrefix) + } else { + message = fmt.Sprintf("%s[Retry %d/%d]", runner.LogMsgPrefix, attemptNumber, runner.MaxRetries) + } + if runner.ErrorMessage != "" { - message = fmt.Sprintf("%s - %s", message, runner.ErrorMessage) + message = fmt.Sprintf("%s %s", message, runner.ErrorMessage) } + if err != nil { - message = fmt.Sprintf("%s: %s", message, err.Error()) + message = fmt.Sprintf("%s - Error: %s", message, err.Error()) } - if err != nil || runner.ErrorMessage != "" { - log.Warn(message) + if err != nil { + if attemptNumber == runner.MaxRetries { + log.Error(fmt.Sprintf("%s - Final attempt failed", message)) + } else { + log.Warn(message) + } } else { - log.Debug(message) + if attemptNumber == 0 { + log.Debug(fmt.Sprintf("%s - Succeeded on first try", message)) + } else { + log.Info(fmt.Sprintf("%s - Succeeded after %d retries", message, attemptNumber)) + } } }