diff --git a/pisa/pisad.py b/pisa/pisad.py index c769201..406df70 100644 --- a/pisa/pisad.py +++ b/pisa/pisad.py @@ -20,8 +20,7 @@ if __name__ == '__main__': start_api() else: - logger.error("[Pisad] bitcoind is running on a different network, check conf.py and bitcoin.conf. " - "Shutting down") + logger.error("bitcoind is running on a different network, check conf.py and bitcoin.conf. Shutting down") else: - logging.error("[Pisad] can't connect to bitcoind. Shutting down") + logging.error("can't connect to bitcoind. Shutting down") diff --git a/pisa/responder.py b/pisa/responder.py index 6e76904..6855e5c 100644 --- a/pisa/responder.py +++ b/pisa/responder.py @@ -183,11 +183,11 @@ class Responder: for uuid, job in self.jobs.items(): # First we check if the dispute transaction is still in the blockchain. If not, the justice can not be # there either, so we'll need to call the reorg manager straight away - dispute_in_chain, _ = check_tx_in_chain(job.dispute_txid, parent='Responder', tx_label='dispute tx') + dispute_in_chain, _ = check_tx_in_chain(job.dispute_txid, logger=logger, tx_label='dispute tx') # If the dispute is there, we can check the justice tx if dispute_in_chain: - justice_in_chain, justice_confirmations = check_tx_in_chain(job.justice_txid, parent='Responder', + justice_in_chain, justice_confirmations = check_tx_in_chain(job.justice_txid, logger=logger, tx_label='justice tx') # If both transactions are there, we only need to update the justice tx confirmation count diff --git a/pisa/tools.py b/pisa/tools.py index 909c64c..a5fbe9c 100644 --- a/pisa/tools.py +++ b/pisa/tools.py @@ -2,12 +2,12 @@ import re from http.client import HTTPException import pisa.conf as conf -from pisa import logging, bitcoin_cli +from pisa import bitcoin_cli, Logger from pisa.utils.auth_proxy import JSONRPCException from pisa.rpc_errors import RPC_INVALID_ADDRESS_OR_KEY -def check_tx_in_chain(tx_id, parent='', tx_label='transaction'): +def check_tx_in_chain(tx_id, logger=Logger(), tx_label='transaction'): tx_in_chain = False confirmations = 0 @@ -17,18 +17,18 @@ def check_tx_in_chain(tx_id, parent='', tx_label='transaction'): if tx_info.get("confirmations"): confirmations = int(tx_info.get("confirmations")) tx_in_chain = True - logging.error("[{}] {} found in the blockchain (txid: {}) ".format(parent, tx_label, tx_id)) + logger.error("{} found in the blockchain (txid: {}) ".format(tx_label), txid=tx_id) else: - logging.error("[{}] {} found in mempool (txid: {}) ".format(parent, tx_label, tx_id)) + logger.error("{} found in mempool (txid: {}) ".format(tx_label), txid=tx_id) except JSONRPCException as e: if e.error.get('code') == RPC_INVALID_ADDRESS_OR_KEY: - logging.error("[{}] {} not found in mempool nor blockchain (txid: {}) ".format(parent, tx_label, tx_id)) + logger.error("{} not found in mempool nor blockchain (txid: {}) ".format(tx_label), txid=tx_id) else: # ToDO: Unhandled errors, check this properly - logging.error("[{}] JSONRPCException. Error code {}".format(parent, e)) + logger.error("JSONRPCException.", error_code=e) return tx_in_chain, confirmations