1
0

logging: basics

This commit is contained in:
SomberNight
2019-04-26 18:52:26 +02:00
parent 4d64e132d7
commit 3385a94753
68 changed files with 681 additions and 563 deletions

View File

@@ -3,9 +3,10 @@ from struct import pack
from electrum import ecc
from electrum.i18n import _
from electrum.util import PrintError, UserCancelled
from electrum.util import UserCancelled
from electrum.keystore import bip39_normalize_passphrase
from electrum.bip32 import BIP32Node, convert_bip32_path_to_list_of_uint32
from electrum.logging import Logger
class GuiMixin(object):
@@ -93,7 +94,7 @@ class GuiMixin(object):
return self.proto.CharacterAck(**char_info)
class KeepKeyClientBase(GuiMixin, PrintError):
class KeepKeyClientBase(GuiMixin, Logger):
def __init__(self, handler, plugin, proto):
assert hasattr(self, 'tx_api') # ProtocolMixin already constructed?
@@ -104,6 +105,7 @@ class KeepKeyClientBase(GuiMixin, PrintError):
self.types = plugin.types
self.msg = None
self.creating_wallet = False
Logger.__init__(self)
self.used()
def __str__(self):
@@ -137,7 +139,7 @@ class KeepKeyClientBase(GuiMixin, PrintError):
def timeout(self, cutoff):
'''Time out the client if the last operation was before cutoff.'''
if self.last_operation < cutoff:
self.print_error("timed out")
self.logger.info("timed out")
self.clear_session()
@staticmethod
@@ -190,13 +192,13 @@ class KeepKeyClientBase(GuiMixin, PrintError):
def clear_session(self):
'''Clear the session to force pin (and passphrase if enabled)
re-entry. Does not leak exceptions.'''
self.print_error("clear session:", self)
self.logger.info(f"clear session: {self}")
self.prevent_timeouts()
try:
super(KeepKeyClientBase, self).clear_session()
except BaseException as e:
# If the device was removed it has the same effect...
self.print_error("clear_session: ignoring error", str(e))
self.logger.info(f"clear_session: ignoring error {e}")
def get_public_node(self, address_n, creating):
self.creating_wallet = creating
@@ -204,7 +206,7 @@ class KeepKeyClientBase(GuiMixin, PrintError):
def close(self):
'''Called when Our wallet was closed or the device removed.'''
self.print_error("closing client")
self.logger.info("closing client")
self.clear_session()
# Release the device
self.transport.close()