pactum
pactum copied to clipboard
Add proper logging for retry mechanism
Is your feature request related to a problem? Please describe. I employed a retry mechanism for my tests, but determining whether the tests were actually retried upon failure was challenging because no related messages were printed in the console/terminal. After going through tosser.js and conducting some debugging, I discovered that retries were indeed occurring.
Describe the solution you'd like In the setResponse() method located in tosser.js, it would be beneficial to include log statements indicating the number of retry attempts within the specified block.
if (!noRetry) {
const scale = delay === 1000 ? 'second' : 'seconds';
log.debug(`Retrying request in ${delay / 1000} ${scale}`);
await helper.sleep(delay);
this.response = await getResponse(this);
}
Additional context As a user, having detailed logging output to the terminal would greatly facilitate debugging issues. I would appreciate a prompt response from you on this matter. @ASaiAnudeep
@Rajaneeshkumar please help raise a PR with the suggested changes.
Hi @ASaiAnudeep , Raised PR https://github.com/pactumjs/pactum/pull/315 for this changes Please review
@Rajaneeshkumar depending on the retry count, the requested change might spam the console output. Instead of changing it into info log just for this usecase, have you tried setting the log level to debug? https://pactumjs.github.io/api/settings/setLogLevel.html#setloglevel
@leelaprasadv I have tried to set the log level to debug to gain more insight into the process. However, this action resulted in a spamming of debug logs from various sources being printed to the console. I want to apply retry logic to all requests in the project globally, not for specific requests. Could you please suggest any other workaround?
@ASaiAnudeep / @leelaprasadv Could you please provide an update on the status of the above request?
closed in https://github.com/pactumjs/pactum/pull/315