From a2804c3de1470db98d8c6aa8a01e2de1aa1718a1 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 5 Sep 2012 07:42:10 +0900 Subject: app wide logging handler --- src/leap/baseapp/eip.py | 9 +++++++-- src/leap/baseapp/leap_app.py | 6 ++++++ src/leap/baseapp/mainwindow.py | 5 ++--- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 029ce0ba..e0da63a2 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -1,3 +1,4 @@ +import logging import time from PyQt4 import QtCore @@ -7,6 +8,8 @@ from leap.baseapp import constants from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection +logger = logging.getLogger(name=__name__) + class EIPConductorApp(object): """ @@ -126,8 +129,10 @@ class EIPConductorApp(object): if self.conductor.with_errors: #XXX how to wait on pkexec??? #something better that this workaround, plz!! - time.sleep(2) - print('errors. disconnect.') + time.sleep(5) + #print('errors. disconnect.') + logger.debug('timeout') + logger.error('errors. disconnect') self.start_or_stopVPN() # is stop state = self.conductor.poll_connection_state() diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index def95da1..85644360 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -1,7 +1,11 @@ +import logging + from PyQt4 import QtGui from leap.gui import mainwindow_rc +logger = logging.getLogger(name=__name__) + class MainWindow(object): """ @@ -79,5 +83,7 @@ technolust") # TODO:make sure to shutdown all child process / threads # in conductor # XXX send signal instead? + logger.info('Shutting down') self.conductor.cleanup() + logger.info('Exiting') QtGui.qApp.quit() diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index ac7fe9c4..e87f5844 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -1,9 +1,6 @@ # vim: set fileencoding=utf-8 : #!/usr/bin/env python import logging -logging.basicConfig() -logger = logging.getLogger(name=__name__) -logger.setLevel(logging.DEBUG) from PyQt4 import QtCore from PyQt4 import QtGui @@ -13,6 +10,8 @@ from leap.baseapp.log import LogPane from leap.baseapp.systray import StatusAwareTrayIcon from leap.baseapp.leap_app import MainWindow +logger = logging.getLogger(name=__name__) + class LeapWindow(QtGui.QMainWindow, MainWindow, EIPConductorApp, -- cgit v1.2.3