logging: log exceptions caught by crash reporter
This commit is contained in:
@@ -13,6 +13,7 @@ from kivy.utils import platform
|
|||||||
from electrum.gui.kivy.i18n import _
|
from electrum.gui.kivy.i18n import _
|
||||||
|
|
||||||
from electrum.base_crash_reporter import BaseCrashReporter
|
from electrum.base_crash_reporter import BaseCrashReporter
|
||||||
|
from electrum.logging import Logger
|
||||||
|
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
@@ -172,9 +173,10 @@ class CrashReportDetails(Factory.Popup):
|
|||||||
print(text)
|
print(text)
|
||||||
|
|
||||||
|
|
||||||
class ExceptionHook(base.ExceptionHandler):
|
class ExceptionHook(base.ExceptionHandler, Logger):
|
||||||
def __init__(self, main_window):
|
def __init__(self, main_window):
|
||||||
super().__init__()
|
base.ExceptionHandler.__init__(self)
|
||||||
|
Logger.__init__(self)
|
||||||
self.main_window = main_window
|
self.main_window = main_window
|
||||||
if not main_window.electrum_config.get(BaseCrashReporter.config_key, default=True):
|
if not main_window.electrum_config.get(BaseCrashReporter.config_key, default=True):
|
||||||
return
|
return
|
||||||
@@ -185,6 +187,7 @@ class ExceptionHook(base.ExceptionHandler):
|
|||||||
|
|
||||||
def handle_exception(self, _inst):
|
def handle_exception(self, _inst):
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
|
self.logger.error('exception caught by crash reporter', exc_info=exc_info)
|
||||||
# Check if this is an exception from within the exception handler:
|
# Check if this is an exception from within the exception handler:
|
||||||
import traceback
|
import traceback
|
||||||
for item in traceback.extract_tb(exc_info[2]):
|
for item in traceback.extract_tb(exc_info[2]):
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ class Exception_Window(BaseCrashReporter, QWidget, MessageBoxMixin, Logger):
|
|||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
Exception_Window._active_window = None
|
Exception_Window._active_window = None
|
||||||
sys.__excepthook__(*self.exc_args)
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def show_never(self):
|
def show_never(self):
|
||||||
@@ -134,16 +133,18 @@ def _show_window(*args):
|
|||||||
Exception_Window._active_window = Exception_Window(*args)
|
Exception_Window._active_window = Exception_Window(*args)
|
||||||
|
|
||||||
|
|
||||||
class Exception_Hook(QObject):
|
class Exception_Hook(QObject, Logger):
|
||||||
_report_exception = QtCore.pyqtSignal(object, object, object, object)
|
_report_exception = QtCore.pyqtSignal(object, object, object, object)
|
||||||
|
|
||||||
def __init__(self, main_window, *args, **kwargs):
|
def __init__(self, main_window, *args, **kwargs):
|
||||||
super(Exception_Hook, self).__init__(*args, **kwargs)
|
QObject.__init__(self, *args, **kwargs)
|
||||||
|
Logger.__init__(self)
|
||||||
if not main_window.config.get(BaseCrashReporter.config_key, default=True):
|
if not main_window.config.get(BaseCrashReporter.config_key, default=True):
|
||||||
return
|
return
|
||||||
self.main_window = main_window
|
self.main_window = main_window
|
||||||
sys.excepthook = self.handler
|
sys.excepthook = self.handler
|
||||||
self._report_exception.connect(_show_window)
|
self._report_exception.connect(_show_window)
|
||||||
|
|
||||||
def handler(self, *args):
|
def handler(self, *exc_info):
|
||||||
self._report_exception.emit(self.main_window, *args)
|
self.logger.error('exception caught by crash reporter', exc_info=exc_info)
|
||||||
|
self._report_exception.emit(self.main_window, *exc_info)
|
||||||
|
|||||||
Reference in New Issue
Block a user