logging: basics
This commit is contained in:
@@ -11,11 +11,15 @@ from electrum.plugin import Device
|
||||
from electrum.transaction import deserialize, Transaction
|
||||
from electrum.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey
|
||||
from electrum.base_wizard import ScriptTypeNotSupported, HWD_SETUP_NEW_WALLET
|
||||
from electrum.logging import get_logger
|
||||
|
||||
from ..hw_wallet import HW_PluginBase
|
||||
from ..hw_wallet.plugin import (is_any_tx_output_on_change_branch, trezor_validate_op_return_output_and_get_data,
|
||||
LibraryFoundButUnusable)
|
||||
|
||||
_logger = get_logger(__name__)
|
||||
|
||||
|
||||
try:
|
||||
import trezorlib
|
||||
import trezorlib.transport
|
||||
@@ -32,8 +36,7 @@ try:
|
||||
|
||||
TREZORLIB = True
|
||||
except Exception as e:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
_logger.exception('error importing trezorlib')
|
||||
TREZORLIB = False
|
||||
|
||||
RECOVERY_TYPE_SCRAMBLED_WORDS, RECOVERY_TYPE_MATRIX = range(2)
|
||||
@@ -145,17 +148,17 @@ class TrezorPlugin(HW_PluginBase):
|
||||
|
||||
def create_client(self, device, handler):
|
||||
try:
|
||||
self.print_error("connecting to device at", device.path)
|
||||
self.logger.info(f"connecting to device at {device.path}")
|
||||
transport = trezorlib.transport.get_transport(device.path)
|
||||
except BaseException as e:
|
||||
self.print_error("cannot connect at", device.path, str(e))
|
||||
self.logger.info(f"cannot connect at {device.path} {e}")
|
||||
return None
|
||||
|
||||
if not transport:
|
||||
self.print_error("cannot connect at", device.path)
|
||||
self.logger.info(f"cannot connect at {device.path}")
|
||||
return
|
||||
|
||||
self.print_error("connected to device at", device.path)
|
||||
self.logger.info(f"connected to device at {device.path}")
|
||||
# note that this call can still raise!
|
||||
return TrezorClientBase(transport, handler, self)
|
||||
|
||||
@@ -208,7 +211,7 @@ class TrezorPlugin(HW_PluginBase):
|
||||
except UserCancelled:
|
||||
exit_code = 1
|
||||
except BaseException as e:
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
self.logger.exception('')
|
||||
handler.show_error(str(e))
|
||||
exit_code = 1
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user