From d924af48dd7b2b49f67fc0a42fc73d47c0d5d01a Mon Sep 17 00:00:00 2001 From: gazbert Date: Wed, 13 Nov 2024 17:09:28 +0000 Subject: [PATCH] #169 - Use parameterised log statements --- .../exchange/ExchangeApiConfigBuilder.java | 10 +++--- .../exchanges/AbstractExchangeAdapter.java | 16 ++++----- .../exchanges/BitfinexExchangeAdapter.java | 20 +++++------ .../exchanges/BitstampExchangeAdapter.java | 20 +++++------ .../exchanges/GeminiExchangeAdapter.java | 19 ++++++----- .../exchanges/KrakenExchangeAdapter.java | 26 +++++++------- .../exchanges/TryModeExchangeAdapter.java | 34 +++++++++---------- 7 files changed, 74 insertions(+), 71 deletions(-) diff --git a/bxbot-core/src/main/java/com/gazbert/bxbot/core/config/exchange/ExchangeApiConfigBuilder.java b/bxbot-core/src/main/java/com/gazbert/bxbot/core/config/exchange/ExchangeApiConfigBuilder.java index 4e35832d..fa41770e 100644 --- a/bxbot-core/src/main/java/com/gazbert/bxbot/core/config/exchange/ExchangeApiConfigBuilder.java +++ b/bxbot-core/src/main/java/com/gazbert/bxbot/core/config/exchange/ExchangeApiConfigBuilder.java @@ -63,8 +63,9 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) { exchangeApiNetworkConfig.setNonFatalErrorCodes(nonFatalErrorCodes); } else { log.info( - "No (optional) NetworkConfiguration NonFatalErrorCodes have been set for Exchange Adapter: {}", - exchangeConfig.getAdapter()); + "No (optional) NetworkConfiguration NonFatalErrorCodes have been set for Exchange " + + "Adapter: " + + exchangeConfig.getAdapter()); } final List nonFatalErrorMessages = networkConfig.getNonFatalErrorMessages(); @@ -72,8 +73,9 @@ public static ExchangeConfigImpl buildConfig(ExchangeConfig exchangeConfig) { exchangeApiNetworkConfig.setNonFatalErrorMessages(nonFatalErrorMessages); } else { log.info( - "No (optional) NetworkConfiguration NonFatalErrorMessages have been set for Exchange Adapter: {}", - exchangeConfig.getAdapter()); + "No (optional) NetworkConfiguration NonFatalErrorMessages have been set for " + + "Exchange Adapter: " + + exchangeConfig.getAdapter()); } exchangeApiConfig.setNetworkConfig(exchangeApiNetworkConfig); diff --git a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/AbstractExchangeAdapter.java b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/AbstractExchangeAdapter.java index 30cae5fb..2731c7bf 100644 --- a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/AbstractExchangeAdapter.java +++ b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/AbstractExchangeAdapter.java @@ -115,7 +115,7 @@ abstract class AbstractExchangeAdapter { * @throws ExchangeNetworkException if a network error occurred trying to connect to the exchange. * This exception allows for recovery from temporary network issues. * @throws TradingApiException if the API call failed for any reason other than a network error. - * This means something really bad as happened. + * This means something awful has happened. */ ExchangeHttpResponse sendNetworkRequest( URL url, String httpMethod, String postData, Map requestHeaders) @@ -125,7 +125,7 @@ ExchangeHttpResponse sendNetworkRequest( final StringBuilder exchangeResponse = new StringBuilder(); try { - log.debug("Using following URL for API call: " + url); + log.debug("Using following URL for API call: {}", url); exchangeConnection = (HttpURLConnection) url.openConnection(); exchangeConnection.setUseCaches(false); @@ -140,7 +140,7 @@ ExchangeHttpResponse sendNetworkRequest( exchangeConnection.setReadTimeout(timeoutInMillis); if (httpMethod.equalsIgnoreCase("POST") && postData != null) { - log.debug("Doing POST with request body: " + postData); + log.debug("Doing POST with request body: {}", postData); try (final OutputStreamWriter outputPostStream = new OutputStreamWriter(exchangeConnection.getOutputStream(), StandardCharsets.UTF_8)) { outputPostStream.write(postData); @@ -236,19 +236,19 @@ void setNetworkConfig(ExchangeConfig exchangeConfig) { log.error(errorMsg); throw new IllegalArgumentException(errorMsg); } - log.info(CONNECTION_TIMEOUT_PROPERTY_NAME + ": " + connectionTimeout); + log.info(CONNECTION_TIMEOUT_PROPERTY_NAME + ": {}", connectionTimeout); final List nonFatalErrorCodesFromConfig = networkConfig.getNonFatalErrorCodes(); if (nonFatalErrorCodesFromConfig != null) { nonFatalNetworkErrorCodes.addAll(nonFatalErrorCodesFromConfig); } - log.info(NON_FATAL_ERROR_CODES_PROPERTY_NAME + ": " + nonFatalNetworkErrorCodes); + log.info(NON_FATAL_ERROR_CODES_PROPERTY_NAME + ": {}", nonFatalNetworkErrorCodes); final List nonFatalErrorMessagesFromConfig = networkConfig.getNonFatalErrorMessages(); if (nonFatalErrorMessagesFromConfig != null) { nonFatalNetworkErrorMessages.addAll(nonFatalErrorMessagesFromConfig); } - log.info(NON_FATAL_ERROR_MESSAGES_PROPERTY_NAME + ": " + nonFatalNetworkErrorMessages); + log.info(NON_FATAL_ERROR_MESSAGES_PROPERTY_NAME + ": {}", nonFatalNetworkErrorMessages); } /** @@ -309,7 +309,7 @@ String getAuthenticationConfigItem(AuthenticationConfig authenticationConfig, St */ String getOtherConfigItem(OtherConfig otherConfig, String itemName) { final String itemValue = otherConfig.getItem(itemName); - log.debug(itemName + ": " + itemValue); + log.debug("{}: {}", itemName, itemValue); return assertItemExists(itemName, itemValue); } @@ -370,7 +370,7 @@ private void setRequestHeaders( if (requestHeaders != null) { for (final Map.Entry requestHeader : requestHeaders.entrySet()) { exchangeConnection.setRequestProperty(requestHeader.getKey(), requestHeader.getValue()); - log.debug("Setting following request header: " + requestHeader); + log.debug("Setting following request header: {}", requestHeader); } } } diff --git a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitfinexExchangeAdapter.java b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitfinexExchangeAdapter.java index 79d83e40..562ff1d3 100644 --- a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitfinexExchangeAdapter.java +++ b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitfinexExchangeAdapter.java @@ -144,7 +144,7 @@ public BitfinexExchangeAdapter() { @Override public void init(ExchangeConfig config) { - log.info("About to initialise Bitfinex ExchangeConfig: " + config); + log.info("About to initialise Bitfinex ExchangeConfig: {}", config); setAuthenticationConfig(config); setNetworkConfig(config); @@ -163,7 +163,7 @@ public MarketOrderBook getMarketOrders(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendPublicRequestToExchange("book/" + marketId); - log.debug("Market Orders response: " + response); + log.debug("Market Orders response: {}", response); final BitfinexOrderBook orderBook = gson.fromJson(response.getPayload(), BitfinexOrderBook.class); @@ -206,7 +206,7 @@ public List getYourOpenOrders(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("orders", null); - log.debug("Open Orders response: " + response); + log.debug("Open Orders response: {}", response); final BitfinexOpenOrders bitfinexOpenOrders = gson.fromJson(response.getPayload(), BitfinexOpenOrders.class); @@ -308,7 +308,7 @@ public String createOrder( // params.put("is_hidden", "false"); final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("order/new", params); - log.debug("Create Order response: " + response); + log.debug("Create Order response: {}", response); final BitfinexNewOrderResponse createOrderResponse = gson.fromJson(response.getPayload(), BitfinexNewOrderResponse.class); @@ -342,7 +342,7 @@ public boolean cancelOrder(String orderId, String marketIdNotNeeded) final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("order/cancel", params); - log.debug("Cancel Order response: " + response); + log.debug("Cancel Order response: {}", response); // Exchange returns order id and other details if successful, a 400 HTTP Status if the order // id was not recognised. @@ -370,7 +370,7 @@ public BigDecimal getLatestMarketPrice(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendPublicRequestToExchange("pubticker/" + marketId); - log.debug("Latest Market Price response: " + response); + log.debug("Latest Market Price response: {}", response); final BitfinexTicker ticker = gson.fromJson(response.getPayload(), BitfinexTicker.class); return ticker.lastPrice; @@ -388,7 +388,7 @@ public BigDecimal getLatestMarketPrice(String marketId) public BalanceInfo getBalanceInfo() throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("balances", null); - log.debug("Balance Info response: " + response); + log.debug("Balance Info response: {}", response); final BitfinexBalances allAccountBalances = gson.fromJson(response.getPayload(), BitfinexBalances.class); @@ -430,7 +430,7 @@ public BigDecimal getPercentageOfBuyOrderTakenForExchangeFee(String marketId) try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("account_infos", null); - log.debug("Buy Fee response: " + response); + log.debug("Buy Fee response: {}", response); // Nightmare to adapt! Just take the top-level taker fees. final BitfinexAccountInfos bitfinexAccountInfos = @@ -455,7 +455,7 @@ public BigDecimal getPercentageOfSellOrderTakenForExchangeFee(String marketId) try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("account_infos", null); - log.debug("Sell Fee response: " + response); + log.debug("Sell Fee response: {}", response); // Nightmare to adapt! Just take the top-level taker fees. final BitfinexAccountInfos bitfinexAccountInfos = @@ -483,7 +483,7 @@ public String getImplName() { public Ticker getTicker(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendPublicRequestToExchange("pubticker/" + marketId); - log.debug("Latest Market Price response: " + response); + log.debug("Latest Market Price response: {}", response); final BitfinexTicker ticker = gson.fromJson(response.getPayload(), BitfinexTicker.class); return new TickerImpl( diff --git a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitstampExchangeAdapter.java b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitstampExchangeAdapter.java index 988d2a08..da3a2a6d 100644 --- a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitstampExchangeAdapter.java +++ b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/BitstampExchangeAdapter.java @@ -139,7 +139,7 @@ public BitstampExchangeAdapter() { @Override public void init(ExchangeConfig config) { - log.info("About to initialise Bitstamp ExchangeConfig: " + config); + log.info("About to initialise Bitstamp ExchangeConfig: {}", config); setAuthenticationConfig(config); setNetworkConfig(config); @@ -158,7 +158,7 @@ public MarketOrderBook getMarketOrders(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendPublicRequestToExchange("order_book/" + marketId); - log.debug("Market Orders response: " + response); + log.debug("Market Orders response: {}", response); final BitstampOrderBook bitstampOrderBook = gson.fromJson(response.getPayload(), BitstampOrderBook.class); @@ -204,7 +204,7 @@ public List getYourOpenOrders(String marketId) try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("open_orders/" + marketId, null); - log.debug("Open Orders response: " + response); + log.debug("Open Orders response: {}", response); final BitstampOrderResponse[] myOpenOrders = gson.fromJson(response.getPayload(), BitstampOrderResponse[].class); @@ -279,7 +279,7 @@ public String createOrder( throw new IllegalArgumentException(errorMsg); } - log.debug("Create Order response: " + response); + log.debug("Create Order response: {}", response); final BitstampOrderResponse createOrderResponse = gson.fromJson(response.getPayload(), BitstampOrderResponse.class); @@ -313,7 +313,7 @@ public boolean cancelOrder(String orderId, String marketIdNotNeeded) final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("cancel_order", params); - log.debug("Cancel Order response: " + response); + log.debug("Cancel Order response: {}", response); final BitstampCancelOrderResponse cancelOrderResponse = gson.fromJson(response.getPayload(), BitstampCancelOrderResponse.class); @@ -339,7 +339,7 @@ public BigDecimal getLatestMarketPrice(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendPublicRequestToExchange("ticker/" + marketId); - log.debug("Latest Market Price response: " + response); + log.debug("Latest Market Price response: {}", response); final BitstampTicker bitstampTicker = gson.fromJson(response.getPayload(), BitstampTicker.class); @@ -358,7 +358,7 @@ public BigDecimal getLatestMarketPrice(String marketId) public BalanceInfo getBalanceInfo() throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange(BALANCE, null); - log.debug("Balance Info response: " + response); + log.debug("Balance Info response: {}", response); final BitstampBalance balances = gson.fromJson(response.getPayload(), BitstampBalance.class); @@ -392,7 +392,7 @@ public BigDecimal getPercentageOfBuyOrderTakenForExchangeFee(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange(BALANCE, null); - log.debug("Buy Fee response: " + response); + log.debug("Buy Fee response: {}", response); final BitstampBalance balances = gson.fromJson(response.getPayload(), BitstampBalance.class); @@ -430,7 +430,7 @@ public BigDecimal getPercentageOfSellOrderTakenForExchangeFee(String marketId) throws TradingApiException, ExchangeNetworkException { try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange(BALANCE, null); - log.debug("Sell Fee response: " + response); + log.debug("Sell Fee response: {}", response); final BitstampBalance balances = gson.fromJson(response.getPayload(), BitstampBalance.class); @@ -473,7 +473,7 @@ public Ticker getTicker(String marketId) throws TradingApiException, ExchangeNet try { final ExchangeHttpResponse response = sendPublicRequestToExchange("ticker/" + marketId); - log.debug("Ticker response: " + response); + log.debug("Ticker response: {}", response); final BitstampTicker bitstampTicker = gson.fromJson(response.getPayload(), BitstampTicker.class); diff --git a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/GeminiExchangeAdapter.java b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/GeminiExchangeAdapter.java index 15685982..b340ee08 100644 --- a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/GeminiExchangeAdapter.java +++ b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/GeminiExchangeAdapter.java @@ -169,7 +169,7 @@ public GeminiExchangeAdapter() { @Override public void init(ExchangeConfig config) { - log.info("About to initialise Gemini ExchangeConfig: " + config); + log.info("About to initialise Gemini ExchangeConfig: {}", config); setAuthenticationConfig(config); setNetworkConfig(config); setOtherConfig(config); @@ -238,7 +238,7 @@ public String createOrder( final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("order/new", params); - log.debug("Create Order response: " + response); + log.debug("Create Order response: {}", response); final GeminiOpenOrder createOrderResponse = gson.fromJson(response.getPayload(), GeminiOpenOrder.class); @@ -270,7 +270,7 @@ public boolean cancelOrder(String orderId, String marketIdNotNeeded) final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("order/cancel", params); - log.debug("Cancel Order response: " + response); + log.debug("Cancel Order response: {}", response); // Exchange returns order id and other details if successful, a 400 HTTP Status if the order // id was not recognised. @@ -299,7 +299,7 @@ public List getYourOpenOrders(String marketId) try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("orders", null); - log.debug("Open Orders response: " + response); + log.debug("Open Orders response: {}", response); final GeminiOpenOrders geminiOpenOrders = gson.fromJson(response.getPayload(), GeminiOpenOrders.class); @@ -357,7 +357,7 @@ public MarketOrderBook getMarketOrders(String marketId) try { final ExchangeHttpResponse response = sendPublicRequestToExchange("book/" + marketId); - log.debug("Market Orders response: " + response); + log.debug("Market Orders response: {}", response); final GeminiOrderBook orderBook = gson.fromJson(response.getPayload(), GeminiOrderBook.class); @@ -400,7 +400,7 @@ public BigDecimal getLatestMarketPrice(String marketId) try { final ExchangeHttpResponse response = sendPublicRequestToExchange("pubticker/" + marketId); - log.debug("Latest Market Price response: " + response); + log.debug("Latest Market Price response: {}", response); final GeminiTicker ticker = gson.fromJson(response.getPayload(), GeminiTicker.class); return ticker.last; @@ -419,7 +419,7 @@ public BalanceInfo getBalanceInfo() throws TradingApiException, ExchangeNetworkE try { final ExchangeHttpResponse response = sendAuthenticatedRequestToExchange("balances", null); - log.debug("Balance Info response: " + response); + log.debug("Balance Info response: {}", response); final GeminiBalances allAccountBalances = gson.fromJson(response.getPayload(), GeminiBalances.class); @@ -490,6 +490,7 @@ private static class GeminiMarketOrder { BigDecimal price; BigDecimal amount; + // ignore the timestamp attribute as per the API spec @Override @@ -799,12 +800,12 @@ private void setOtherConfig(ExchangeConfig exchangeConfig) { final String buyFeeInConfig = getOtherConfigItem(otherConfig, BUY_FEE_PROPERTY_NAME); buyFeePercentage = new BigDecimal(buyFeeInConfig).divide(new BigDecimal("100"), 8, RoundingMode.HALF_UP); - log.info("Buy fee % in BigDecimal format: " + buyFeePercentage); + log.info("Buy fee % in BigDecimal format: {}", buyFeePercentage); final String sellFeeInConfig = getOtherConfigItem(otherConfig, SELL_FEE_PROPERTY_NAME); sellFeePercentage = new BigDecimal(sellFeeInConfig).divide(new BigDecimal("100"), 8, RoundingMode.HALF_UP); - log.info("Sell fee % in BigDecimal format: " + sellFeePercentage); + log.info("Sell fee % in BigDecimal format: {}", sellFeePercentage); } // -------------------------------------------------------------------------- diff --git a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/KrakenExchangeAdapter.java b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/KrakenExchangeAdapter.java index 6d37d7eb..9e503096 100644 --- a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/KrakenExchangeAdapter.java +++ b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/KrakenExchangeAdapter.java @@ -200,7 +200,7 @@ public KrakenExchangeAdapter() { @Override public void init(ExchangeConfig config) { - log.info("About to initialise Kraken ExchangeConfig: " + config); + log.info("About to initialise Kraken ExchangeConfig: {}", config); initGson(); setAuthenticationConfig(config); setNetworkConfig(config); @@ -227,7 +227,7 @@ public MarketOrderBook getMarketOrders(String marketId) params.put("pair", marketId); response = sendPublicRequestToExchange("Depth", params); - log.debug("Market Orders response: " + response); + log.debug("Market Orders response: {}", response); if (response.getStatusCode() == HttpURLConnection.HTTP_OK) { final Type resultType = @@ -272,7 +272,7 @@ public List getYourOpenOrders(String marketId) try { response = sendAuthenticatedRequestToExchange("OpenOrders", null); - log.debug("Open Orders response: " + response); + log.debug("Open Orders response: {}", response); if (response.getStatusCode() == HttpURLConnection.HTTP_OK) { @@ -345,7 +345,7 @@ public String createOrder( "volume", new DecimalFormat(volumePrecision, getDecimalFormatSymbols()).format(quantity)); response = sendAuthenticatedRequestToExchange("AddOrder", params); - log.debug("Create Order response: " + response); + log.debug("Create Order response: {}", response); if (response.getStatusCode() == HttpURLConnection.HTTP_OK) { @@ -398,7 +398,7 @@ public boolean cancelOrder(String orderId, String marketIdNotNeeded) params.put("txid", orderId); response = sendAuthenticatedRequestToExchange("CancelOrder", params); - log.debug("Cancel Order response: " + response); + log.debug("Cancel Order response: {}", response); if (response.getStatusCode() == HttpURLConnection.HTTP_OK) { @@ -447,7 +447,7 @@ public BigDecimal getLatestMarketPrice(String marketId) params.put("pair", marketId); response = sendPublicRequestToExchange("Ticker", params); - log.debug("Latest Market Price response: " + response); + log.debug("Latest Market Price response: {}", response); if (response.getStatusCode() == HttpURLConnection.HTTP_OK) { @@ -497,7 +497,7 @@ public BalanceInfo getBalanceInfo() throws TradingApiException, ExchangeNetworkE try { response = sendAuthenticatedRequestToExchange("Balance", null); - log.debug("Balance Info response: " + response); + log.debug("Balance Info response: {}", response); if (response.getStatusCode() == HttpURLConnection.HTTP_OK) { final Type resultType = new TypeToken>() {}.getType(); @@ -558,7 +558,7 @@ public Ticker getTicker(String marketId) throws TradingApiException, ExchangeNet params.put("pair", marketId); response = sendPublicRequestToExchange("Ticker", params); - log.debug("Ticker response: " + response); + log.debug("Ticker response: {}", response); if (response.getStatusCode() == HttpURLConnection.HTTP_OK) { @@ -898,7 +898,7 @@ public KrakenTickerResult deserialize( context.deserialize(jsonTickerParam.getValue(), List.class); krakenTickerResult.put("p", vWapDetails.get(1)); } - default -> log.warn("Received unexpected Ticker param - ignoring: " + key); + default -> log.warn("Received unexpected Ticker param - ignoring: {}", key); } } } @@ -1074,18 +1074,18 @@ private void setOtherConfig(ExchangeConfig exchangeConfig) { final String buyFeeInConfig = getOtherConfigItem(otherConfig, BUY_FEE_PROPERTY_NAME); buyFeePercentage = new BigDecimal(buyFeeInConfig).divide(new BigDecimal("100"), 8, RoundingMode.HALF_UP); - log.info("Buy fee % in BigDecimal format: " + buyFeePercentage); + log.info("Buy fee % in BigDecimal format: {}", buyFeePercentage); final String sellFeeInConfig = getOtherConfigItem(otherConfig, SELL_FEE_PROPERTY_NAME); sellFeePercentage = new BigDecimal(sellFeeInConfig).divide(new BigDecimal("100"), 8, RoundingMode.HALF_UP); - log.info("Sell fee % in BigDecimal format: " + sellFeePercentage); + log.info("Sell fee % in BigDecimal format: {}", sellFeePercentage); final String keepAliveDuringMaintenanceConfig = getOtherConfigItem(otherConfig, KEEP_ALIVE_DURING_MAINTENANCE_PROPERTY_NAME); if (!keepAliveDuringMaintenanceConfig.isEmpty()) { keepAliveDuringMaintenance = Boolean.parseBoolean(keepAliveDuringMaintenanceConfig); - log.info("Keep Alive During Maintenance: " + keepAliveDuringMaintenance); + log.info("Keep Alive During Maintenance: {}", keepAliveDuringMaintenance); } else { log.info(KEEP_ALIVE_DURING_MAINTENANCE_PROPERTY_NAME + " is not set in exchange.yaml"); } @@ -1103,7 +1103,7 @@ private void loadPairPrecisionConfig() { gson.fromJson(response.getPayload(), type); if (krakenResponse.error != null && !krakenResponse.error.isEmpty()) { - log.error(String.format("Error when fetching pair precision: %s", krakenResponse.error)); + log.error("Error when fetching pair precision: {}", krakenResponse.error); return; } diff --git a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/TryModeExchangeAdapter.java b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/TryModeExchangeAdapter.java index e5b32286..f2d01db3 100644 --- a/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/TryModeExchangeAdapter.java +++ b/bxbot-exchanges/src/main/java/com/gazbert/bxbot/exchanges/TryModeExchangeAdapter.java @@ -101,7 +101,7 @@ public TryModeExchangeAdapter() { @Override public void init(ExchangeConfig config) { - log.info("About to initialise try-mode adapter with the following exchange config: " + config); + log.info("About to initialise try-mode adapter with the following exchange config: {}", config); setOtherConfig(config); initializeAdapterDelegation(config); } @@ -126,7 +126,7 @@ public List getYourOpenOrders(String marketId) final List result = new LinkedList<>(); if (currentOpenOrder != null) { result.add(currentOpenOrder); - log.info("getYourOpenOrders: Found an open DUMMY order: " + currentOpenOrder); + log.info("getYourOpenOrders: Found an open DUMMY order: {}", currentOpenOrder); } else { log.info("getYourOpenOrders: no open order found. Return empty order list"); } @@ -148,7 +148,7 @@ public String createOrder( currentOpenOrder = new OpenOrderImpl( newOrderId, creationDate, marketId, orderType, price, quantity, quantity, total); - log.info("Created a new dummy order: " + currentOpenOrder); + log.info("Created a new dummy order: {}", currentOpenOrder); checkOpenOrderExecution(marketId); return newOrderId; } @@ -168,7 +168,7 @@ public boolean cancelOrder(String orderId, String marketId) + ", actual: " + orderId); } - log.info("The following order is canceled: " + currentOpenOrder); + log.info("The following order is canceled: {}", currentOpenOrder); currentOpenOrder = null; return true; } @@ -187,7 +187,7 @@ public BalanceInfo getBalanceInfo() { availableBalances.put(simulatedBaseCurrency, simulatedBaseCurrencyBalance); availableBalances.put(simulatedCounterCurrency, simulatedCounterCurrencyBalance); final BalanceInfo currentBalance = new BalanceInfoImpl(availableBalances, new HashMap<>()); - log.info("Return the following simulated balances: " + currentBalance); + log.info("Return the following simulated balances: {}", currentBalance); return currentBalance; } @@ -213,39 +213,39 @@ private void setOtherConfig(ExchangeConfig exchangeConfig) { final OtherConfig otherConfig = getOtherConfig(exchangeConfig); simulatedBaseCurrency = getOtherConfigItem(otherConfig, SIMULATED_BASE_CURRENCY_PROPERTY_NAME); - log.info("Base currency to be simulated: " + simulatedBaseCurrency); + log.info("Base currency to be simulated: {}", simulatedBaseCurrency); final String startingBaseBalanceInConfig = getOtherConfigItem(otherConfig, SIMULATED_BASE_CURRENCY_START_BALANCE_PROPERTY_NAME); simulatedBaseCurrencyBalance = new BigDecimal(startingBaseBalanceInConfig); log.info( - "Base currency balance at simulation start in BigDecimal format: " - + simulatedBaseCurrencyBalance); + "Base currency balance at simulation start in BigDecimal format: {}", + simulatedBaseCurrencyBalance); simulatedCounterCurrency = getOtherConfigItem(otherConfig, SIMULATED_COUNTER_CURRENCY_PROPERTY_NAME); - log.info("Counter currency to be simulated: " + simulatedCounterCurrency); + log.info("Counter currency to be simulated: {}", simulatedCounterCurrency); final String startingBalanceInConfig = getOtherConfigItem(otherConfig, SIMULATED_COUNTER_CURRENCY_START_BALANCE_PROPERTY_NAME); simulatedCounterCurrencyBalance = new BigDecimal(startingBalanceInConfig); log.info( - "Counter currency balance at simulation start in BigDecimal format: " - + simulatedCounterCurrencyBalance); + "Counter currency balance at simulation start in BigDecimal format: {}", + simulatedCounterCurrencyBalance); final String sellFeeInConfig = getOtherConfigItem(otherConfig, SIMULATED_SELL_FEE_PROPERTY_NAME); simulatedSellFee = new BigDecimal(sellFeeInConfig); - log.info("Sell Fee at simulation start in BigDecimal format: " + simulatedSellFee); + log.info("Sell Fee at simulation start in BigDecimal format: {}", simulatedSellFee); final String buyFeeInConfig = getOtherConfigItem(otherConfig, SIMULATED_BUY_FEE_PROPERTY_NAME); simulatedBuyFee = new BigDecimal(buyFeeInConfig); - log.info("Buy Fee at simulation start in BigDecimal format: " + simulatedBuyFee); + log.info("Buy Fee at simulation start in BigDecimal format: {}", simulatedBuyFee); delegateExchangeClassName = getOtherConfigItem(otherConfig, DELEGATE_ADAPTER_CLASS_PROPERTY_NAME); log.info( - "Delegate exchange adapter to be used for public API calls: " + delegateExchangeClassName); + "Delegate exchange adapter to be used for public API calls: {}", delegateExchangeClassName); log.info("Try-mode adapter config successfully loaded."); } @@ -255,13 +255,13 @@ private void initializeAdapterDelegation(ExchangeConfig config) { } private ExchangeAdapter createDelegateExchangeAdapter() { - log.info("Creating the delegate exchange adapter: " + delegateExchangeClassName + "..."); + log.info("Creating the delegate exchange adapter: {}...", delegateExchangeClassName); try { final Class componentClass = Class.forName(delegateExchangeClassName); final Object rawComponentObject = componentClass.getDeclaredConstructor().newInstance(); log.info( - "Successfully created the delegate exchange adapter class for: " - + delegateExchangeClassName); + "Successfully created the delegate exchange adapter class for: {}", + delegateExchangeClassName); return (ExchangeAdapter) rawComponentObject; } catch (ClassNotFoundException | InstantiationException