From 98f9d7cc21e00a8b47e053051a92ea044c43b215 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sun, 27 Aug 2017 16:50:59 +0300 Subject: [PATCH] use lazy-evaluating form of logger (pylint W1202) --- analyze.py | 2 +- main.py | 12 ++++++------ rpc/telegram.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/analyze.py b/analyze.py index bc14b439e..1e53ffdd5 100644 --- a/analyze.py +++ b/analyze.py @@ -89,7 +89,7 @@ def get_buy_signal(pair): return False signal = latest['underpriced'] == 1 - logger.debug('buy_trigger: {} (pair={}, signal={})'.format(latest['date'], pair, signal)) + logger.debug('buy_trigger: %s (pair=%s, signal=%s)', latest['date'], pair, signal) return signal diff --git a/main.py b/main.py index 7a60a73f8..d6e6b6701 100755 --- a/main.py +++ b/main.py @@ -109,7 +109,7 @@ class TradeThread(threading.Thread): trade.open_order_id = None # Check if this trade can be marked as closed if close_trade_if_fulfilled(trade): - logger.info('No open orders found and trade is fulfilled. Marking {} as closed ...'.format(trade)) + logger.info('No open orders found and trade is fulfilled. Marking %s as closed ...', trade) continue # Check if we can sell our current pair @@ -144,7 +144,7 @@ def handle_trade(trade): if not trade.is_open: raise ValueError('attempt to handle closed trade: {}'.format(trade)) - logger.debug('Handling open trade {} ...'.format(trade)) + logger.debug('Handling open trade %s ...', trade) # Get current rate current_rate = api_wrapper.get_ticker(trade.pair)['bid'] current_profit = 100 * ((current_rate - trade.open_rate) / trade.open_rate) @@ -171,7 +171,7 @@ def handle_trade(trade): TelegramHandler.send_msg(message) return else: - logger.debug('Threshold not reached. (cur_profit: {}%)'.format(round(current_profit, 2))) + logger.debug('Threshold not reached. (cur_profit: %1.2f%%)', current_profit) except ValueError: logger.exception('Unable to handle open order') @@ -182,7 +182,7 @@ def create_trade(stake_amount: float, exchange): :param stake_amount: amount of btc to spend :param exchange: exchange to use """ - logger.info('Creating new trade with stake_amount: {} ...'.format(stake_amount)) + logger.info('Creating new trade with stake_amount: %f ...', stake_amount) whitelist = CONFIG[exchange.name.lower()]['pair_whitelist'] # Check if btc_amount is fulfilled if api_wrapper.get_balance(CONFIG['stake_currency']) < stake_amount: @@ -196,7 +196,7 @@ def create_trade(stake_amount: float, exchange): for trade in trades: if trade.pair in whitelist: whitelist.remove(trade.pair) - logger.debug('Ignoring {} in pair whitelist'.format(trade.pair)) + logger.debug('Ignoring %s in pair whitelist', trade.pair) if not whitelist: raise ValueError('No pair in whitelist') @@ -231,7 +231,7 @@ def create_trade(stake_amount: float, exchange): if __name__ == '__main__': - logger.info('Starting freqtrade {}'.format(__version__)) + logger.info('Starting freqtrade %s', __version__) TelegramHandler.listen() while True: time.sleep(0.5) diff --git a/rpc/telegram.py b/rpc/telegram.py index 1c6c1225f..7c18ec691 100644 --- a/rpc/telegram.py +++ b/rpc/telegram.py @@ -36,10 +36,10 @@ def authorized_only(command_handler): chat_id = int(conf['telegram']['chat_id']) if int(update.message.chat_id) == chat_id: - logger.info('Executing handler: {} for chat_id: {}'.format(command_handler.__name__, chat_id)) + logger.info('Executing handler: %s for chat_id: %s', command_handler.__name__, chat_id) return command_handler(*args, **kwargs) else: - logger.info('Rejected unauthorized message from: {}'.format(update.message.chat_id)) + logger.info('Rejected unauthorized message from: %s', update.message.chat_id) return wrapper @@ -307,7 +307,7 @@ class TelegramHandler(object): except NetworkError as error: # Sometimes the telegram server resets the current connection, # if this is the case we send the message again. - logger.warning('Got Telegram NetworkError: {}! trying one more time'.format(error.message)) + logger.warning('Got Telegram NetworkError: %s! Trying one more time.', error.message) bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode) except Exception: logger.exception('Exception occurred within Telegram API')