Improve some of the progress logging

This commit is contained in:
ghubstan 2022-06-29 18:50:57 -03:00
parent 9307c08d4d
commit 8ed39eb8bf
No known key found for this signature in database
GPG Key ID: E35592D6800A861E

View File

@ -710,8 +710,7 @@ public abstract class AbstractBot {
* Print information about offers taken during bot simulation. * Print information about offers taken during bot simulation.
*/ */
protected void printDryRunProgress() { protected void printDryRunProgress() {
if (isDryRun && offersTakenDuringDryRun.size() > 0) { if (isDryRun && !offersTakenDuringDryRun.isEmpty()) {
log.info("You have \"taken\" {} offer(s) during dry run:", offersTakenDuringDryRun.size());
printOffersSummary(offersTakenDuringDryRun); printOffersSummary(offersTakenDuringDryRun);
} }
} }
@ -721,8 +720,6 @@ public abstract class AbstractBot {
*/ */
protected void addToOffersTaken(OfferInfo offer) { protected void addToOffersTaken(OfferInfo offer) {
offersTakenDuringDryRun.add(offer); offersTakenDuringDryRun.add(offer);
printOfferSummary(offer);
log.info("Did not actually take that offer during this simulation.");
} }
/** /**
@ -828,7 +825,7 @@ public abstract class AbstractBot {
} }
/** /**
* Print the day's completed trades since midnight today, then: * Print the day's completed trades since midnight today, and number of offers taken during the bot session, then,
* <p> * <p>
* If numOffersTaken >= maxTakeOffers, and trade completion is being simulated on regtest, shut down the bot. * If numOffersTaken >= maxTakeOffers, and trade completion is being simulated on regtest, shut down the bot.
* <p> * <p>
@ -843,15 +840,15 @@ public abstract class AbstractBot {
*/ */
protected void maybeShutdownAfterSuccessfulTradeCreation(int numOffersTaken, int maxTakeOffers) { protected void maybeShutdownAfterSuccessfulTradeCreation(int numOffersTaken, int maxTakeOffers) {
printTradesSummaryForTodayIfWalletIsUnlocked(); printTradesSummaryForTodayIfWalletIsUnlocked();
if (!isDryRun) {
// If the bot is not in dryrun mode, lock the wallet. If dryrun=true, leave the wallet unlocked until the log.info("You {} have taken {} offer(s) during this bot's {}",
// timeout expires, so the user can look at data in the daemon with the CLI (a convenience in dev/test). isDryRun ? "would" : "",
try { numOffersTaken,
lockWallet(); isDryRun ? "dryrun:" : "session.");
} catch (NonFatalException ex) { if (isDryRun) {
log.warn(ex.getMessage()); printDryRunProgress();
}
} }
if (numOffersTaken >= maxTakeOffers) { if (numOffersTaken >= maxTakeOffers) {
isShutdown = true; isShutdown = true;
if (canSimulatePaymentSteps) { if (canSimulatePaymentSteps) {
@ -868,8 +865,6 @@ public abstract class AbstractBot {
stopDaemon(); stopDaemon();
} }
exit(0); exit(0);
} else {
log.info("You have taken {} offers during this bot session.", numOffersTaken);
} }
} }