summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/app.py25
-rw-r--r--src/leap/baseapp/eip.py9
-rw-r--r--src/leap/baseapp/leap_app.py6
-rw-r--r--src/leap/baseapp/mainwindow.py5
-rw-r--r--src/leap/eip/checks.py7
-rw-r--r--src/leap/eip/config.py2
-rw-r--r--src/leap/eip/eipconnection.py6
-rw-r--r--src/leap/eip/openvpnconnection.py6
8 files changed, 39 insertions, 27 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index db48701b..3864ffeb 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -6,9 +6,6 @@ from PyQt4.QtGui import (QApplication, QSystemTrayIcon, QMessageBox)
from leap.baseapp.mainwindow import LeapWindow
-logging.basicConfig()
-logger = logging.getLogger(name=__name__)
-
def main():
"""
@@ -20,17 +17,29 @@ def main():
parser, opts = leap_argparse.init_leapc_args()
debug = getattr(opts, 'debug', False)
- #XXX get debug level and set logger accordingly
if debug:
- logger.setLevel('DEBUG')
- logger.debug('args: %s' % opts)
+ level = logging.DEBUG
+ else:
+ level = logging.WARNING
+
+ 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')
+ console.setFormatter(formatter)
+ logger.addHandler(console)
+ logger.debug('args: %s' % opts)
+ logger.info('Starting app')
app = QApplication(sys.argv)
if not QSystemTrayIcon.isSystemTrayAvailable():
QMessageBox.critical(None, "Systray",
- "I couldn't detect any \
-system tray on this system.")
+ "I couldn't detect"
+ "any system tray on this system.")
sys.exit(1)
if not debug:
QApplication.setQuitOnLastWindowClosed(False)
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</i>")
# 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,
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
index 1b7c2e1b..4a2a9599 100644
--- a/src/leap/eip/checks.py
+++ b/src/leap/eip/checks.py
@@ -1,12 +1,7 @@
-#import json
import logging
import ssl
import os
-logging.basicConfig()
-logger = logging.getLogger(name=__name__)
-logger.setLevel(logging.DEBUG)
-
import requests
from leap.base import constants as baseconstants
@@ -17,6 +12,8 @@ from leap.eip import exceptions as eipexceptions
from leap.eip import specs as eipspecs
from leap.util.fileutil import mkdir_p
+logger = logging.getLogger(name=__name__)
+
"""
EIPConfigChecker
----------
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py
index 810a5a8d..f4b979ce 100644
--- a/src/leap/eip/config.py
+++ b/src/leap/eip/config.py
@@ -10,9 +10,7 @@ from leap.baseapp.permcheck import (is_pkexec_in_system,
from leap.eip import exceptions as eip_exceptions
from leap.eip import specs as eipspecs
-logging.basicConfig()
logger = logging.getLogger(name=__name__)
-logger.setLevel('DEBUG')
class EIPConfig(baseconfig.JSONLeapConfig):
diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py
index 386b71be..3a6f4d49 100644
--- a/src/leap/eip/eipconnection.py
+++ b/src/leap/eip/eipconnection.py
@@ -4,14 +4,12 @@ EIP Connection Class
from __future__ import (absolute_import,)
import logging
-logging.basicConfig()
-logger = logging.getLogger(name=__name__)
-logger.setLevel(logging.DEBUG)
-
from leap.eip.checks import EIPConfigChecker
from leap.eip import exceptions as eip_exceptions
from leap.eip.openvpnconnection import OpenVPNConnection
+logger = logging.getLogger(name=__name__)
+
class EIPConnection(OpenVPNConnection):
"""
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index 32fa55b1..48252e10 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -7,9 +7,7 @@ import socket
import time
from functools import partial
-logging.basicConfig()
logger = logging.getLogger(name=__name__)
-logger.setLevel(logging.DEBUG)
from leap.base.connection import Connection
from leap.util.coroutines import spawn_and_watch_process
@@ -45,6 +43,7 @@ to be triggered for each one of them.
:type watcher_cb: function
:type signal_map: dict
"""
+ logger.debug('init openvpn connection')
self.debug = debug
#print('conductor:%s' % debug)
@@ -192,7 +191,8 @@ to be triggered for each one of them.
#
def forget_errors(self):
- print('forgetting errors')
+ #print('forgetting errors')
+ logger.debug('forgetting errors')
self.with_errors = False
def connect_to_management(self):