summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/leap/app.py15
-rw-r--r--src/leap/gui/mainwindow.py37
-rw-r--r--src/leap/gui/ui/mainwindow.ui10
3 files changed, 57 insertions, 5 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index 797cea8a..03552edb 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -26,6 +26,7 @@ from PySide import QtCore, QtGui
from leap.common.events import server as event_server
from leap.util import __version__ as VERSION
from leap.util import leap_argparse
+from leap.util.leap_log_handler import LeapLogHandler
from leap.gui import locale_rc
from leap.gui import twisted_main
from leap.gui.mainwindow import MainWindow
@@ -33,6 +34,7 @@ from leap.platform_init import IS_MAC
from leap.platform_init.locks import we_are_the_one_and_only
from leap.services.tx import leap_services
+
import codecs
codecs.register(lambda name: codecs.lookup('utf-8')
if name == 'cp65001' else None)
@@ -75,16 +77,23 @@ def main():
else:
level = logging.WARNING
+ # Console logger
logger = logging.getLogger(name='leap')
logger.setLevel(level)
console = logging.StreamHandler()
console.setLevel(level)
- formatter = logging.Formatter(
- '%(asctime)s '
- '- %(name)s - %(levelname)s - %(message)s')
+ log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
+ formatter = logging.Formatter(log_format)
console.setFormatter(formatter)
logger.addHandler(console)
+ # LEAP custom handler
+ leap_handler = LeapLogHandler()
+ leap_handler.setLevel(level)
+ logger.addHandler(leap_handler)
+
+ logger.debug('Leap handler plugged!')
+
if not we_are_the_one_and_only():
# leap-client is already running
logger.warning("Tried to launch more than one instance "
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index a8aa1b1c..12187f51 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -35,6 +35,7 @@ from leap.common.events import events_pb2 as proto
from leap.config.leapsettings import LeapSettings
from leap.config.providerconfig import ProviderConfig
from leap.crypto.srpauth import SRPAuth
+from leap.gui.loggerwindow import LoggerWindow
from leap.gui.wizard import Wizard
from leap.services.eip.eipbootstrapper import EIPBootstrapper
from leap.services.eip.eipconfig import EIPConfig
@@ -208,6 +209,7 @@ class MainWindow(QtGui.QMainWindow):
self.ui.action_about_leap.triggered.connect(self._about)
self.ui.action_quit.triggered.connect(self.quit)
self.ui.action_wizard.triggered.connect(self._launch_wizard)
+ self.ui.action_show_logs.triggered.connect(self._show_logger_window)
self.raise_window.connect(self._do_raise_mainwindow)
# Used to differentiate between real quits and close to tray
@@ -249,6 +251,8 @@ class MainWindow(QtGui.QMainWindow):
self._wizard = None
self._wizard_firstrun = False
+ self._logger_window = None
+
self._bypass_checks = bypass_checks
self._soledad = None
@@ -282,6 +286,35 @@ class MainWindow(QtGui.QMainWindow):
self._wizard.exec_()
self._wizard = None
+ def _get_leap_logging_handler(self):
+ """
+ Gets the leap handler from the top level logger
+
+ :return: a logging handler or None
+ :rtype: LeapLogHandler or None
+ """
+ from leap.util.leap_log_handler import LeapLogHandler
+ leap_logger = logging.getLogger('leap')
+ for h in leap_logger.handlers:
+ if isinstance(h, LeapLogHandler):
+ return h
+ return None
+
+ def _show_logger_window(self):
+ """
+ Displays the window with the history of messages logged until now
+ and displays the new ones on arrival.
+ """
+ if self._logger_window is None:
+ leap_log_handler = self._get_leap_logging_handler()
+ if leap_log_handler is None:
+ logger.error('Leap logger handler not found')
+ else:
+ self._logger_window = LoggerWindow(handler=leap_log_handler)
+ self._logger_window.show()
+ else:
+ self._logger_window.show()
+
def _remember_state_changed(self, state):
enable = True if state == QtCore.Qt.Checked else False
self.ui.chkAutoLogin.setEnabled(enable)
@@ -1101,6 +1134,10 @@ class MainWindow(QtGui.QMainWindow):
self._really_quit = True
if self._wizard:
self._wizard.close()
+
+ if self._logger_window:
+ self._logger_window.close()
+
self.close()
if self._quit_callback:
diff --git a/src/leap/gui/ui/mainwindow.ui b/src/leap/gui/ui/mainwindow.ui
index b42ff180..fdf5c167 100644
--- a/src/leap/gui/ui/mainwindow.ui
+++ b/src/leap/gui/ui/mainwindow.ui
@@ -396,7 +396,7 @@
<x>0</x>
<y>0</y>
<width>415</width>
- <height>25</height>
+ <height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuSession">
@@ -417,9 +417,10 @@
</widget>
<widget class="QMenu" name="menuSettings">
<property name="title">
- <string>S&amp;ettings</string>
+ <string>&amp;Utils</string>
</property>
<addaction name="action_wizard"/>
+ <addaction name="action_show_logs"/>
</widget>
<addaction name="menuSession"/>
<addaction name="menuSettings"/>
@@ -451,6 +452,11 @@
<string>&amp;Wizard</string>
</property>
</action>
+ <action name="action_show_logs">
+ <property name="text">
+ <string>Show &amp;logs</string>
+ </property>
+ </action>
</widget>
<tabstops>
<tabstop>lnUser</tabstop>