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

@@ -45,9 +45,10 @@ import PyQt5.QtCore as QtCore
from electrum.i18n import _, set_language
from electrum.plugin import run_hook
from electrum.base_wizard import GoBack
from electrum.util import (UserCancelled, PrintError, profiler,
from electrum.util import (UserCancelled, profiler,
WalletFileException, BitcoinException, get_new_wallet_name)
from electrum.wallet import Wallet, Abstract_Wallet
from electrum.logging import Logger
from .installwizard import InstallWizard, WalletAlreadyOpenInMemory
@@ -78,11 +79,12 @@ class QNetworkUpdatedSignalObject(QObject):
network_updated_signal = pyqtSignal(str, object)
class ElectrumGui(PrintError):
class ElectrumGui(Logger):
@profiler
def __init__(self, config, daemon, plugins):
set_language(config.get('language', get_default_language()))
Logger.__init__(self)
# Uncomment this call to verify objects are being properly
# GC-ed when windows are closed
#network.add_jobs([DebugMem([Abstract_Wallet, SPV, Synchronizer,
@@ -129,7 +131,7 @@ class ElectrumGui(PrintError):
self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
except BaseException as e:
use_dark_theme = False
self.print_error('Error setting dark theme: {}'.format(repr(e)))
self.logger.warning(f'Error setting dark theme: {repr(e)}')
# Even if we ourselves don't set the dark theme,
# the OS/window manager/etc might set *a dark theme*.
# Hence, try to choose colors accordingly:
@@ -221,7 +223,7 @@ class ElectrumGui(PrintError):
try:
wallet = self.daemon.load_wallet(path, None)
except BaseException as e:
traceback.print_exc(file=sys.stdout)
self.logger.exception('')
QMessageBox.warning(None, _('Error'),
_('Cannot load wallet') + ' (1):\n' + str(e))
# if app is starting, still let wizard to appear
@@ -239,7 +241,7 @@ class ElectrumGui(PrintError):
else:
window = self._create_window_for_wallet(wallet)
except BaseException as e:
traceback.print_exc(file=sys.stdout)
self.logger.exception('')
QMessageBox.warning(None, _('Error'),
_('Cannot create window for wallet') + ':\n' + str(e))
if app_is_starting:
@@ -271,7 +273,7 @@ class ElectrumGui(PrintError):
except WalletAlreadyOpenInMemory as e:
return e.wallet
except (WalletFileException, BitcoinException) as e:
traceback.print_exc(file=sys.stderr)
self.logger.exception('')
QMessageBox.warning(None, _('Error'),
_('Cannot load wallet') + ' (2):\n' + str(e))
return
@@ -311,7 +313,7 @@ class ElectrumGui(PrintError):
except GoBack:
return
except BaseException as e:
traceback.print_exc(file=sys.stdout)
self.logger.exception('')
return
self.timer.start()
self.config.open_last_wallet()
@@ -346,5 +348,5 @@ class ElectrumGui(PrintError):
# on some platforms the exec_ call may not return, so use clean_up()
def stop(self):
self.print_error('closing GUI')
self.logger.info('closing GUI')
self.app.quit()