From dd2619bd3bc8cbb1a584b3e04299214c36d927ef Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:55:32 -0300 Subject: [PATCH] Tidy up "Here are today's completed trades" logging --- .../src/main/java/bisq/bots/AbstractBot.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/java-examples/src/main/java/bisq/bots/AbstractBot.java b/java-examples/src/main/java/bisq/bots/AbstractBot.java index 1aaf28c..18a6d81 100644 --- a/java-examples/src/main/java/bisq/bots/AbstractBot.java +++ b/java-examples/src/main/java/bisq/bots/AbstractBot.java @@ -593,11 +593,10 @@ public abstract class AbstractBot { */ protected void printTradesSummaryForTodayIfWalletIsUnlocked() { try { - log.info("Here are today's completed trades:"); printTradesSummaryForToday(CLOSED); } catch (StatusRuntimeException grpcException) { if (walletIsLocked(grpcException)) { - log.error("Cannot retrieve trades while API daemon's wallet is locked."); + log.error("Cannot show today's trades while API daemon's wallet is locked."); } else { throw grpcException; } @@ -614,7 +613,12 @@ public abstract class AbstractBot { var trades = getTrades(category).stream() .filter(t -> t.getDate() >= midnightToday) .collect(Collectors.toList()); - BotUtils.printTradesSummary(category, trades); + if (trades.isEmpty()) { + log.info("No trades have been completed today."); + } else { + log.info("Here are today's completed trades:"); + BotUtils.printTradesSummary(category, trades); + } } /** @@ -805,7 +809,6 @@ public abstract class AbstractBot { * @param maxTakeOffers the max number of offers that can be taken during bot run */ protected void maybeShutdownAfterSuccessfulSwap(int numOffersTaken, int maxTakeOffers) { - log.info("Here are today's completed trades:"); printTradesSummaryForToday(CLOSED); if (!isDryRun) {