summaryrefslogtreecommitdiff
path: root/src/leap/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/app.py')
-rw-r--r--src/leap/app.py35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/leap/app.py b/src/leap/app.py
index db48701b..5849848c 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,39 @@ def main():
parser, opts = leap_argparse.init_leapc_args()
debug = getattr(opts, 'debug', False)
- #XXX get debug level and set logger accordingly
+ # XXX get severity from command line args
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)
+
+ logfile = getattr(opts, 'log_file', False)
+ if logfile:
+ logger.debug('setting logfile to %s ', logfile)
+ fileh = logging.FileHandler(logfile)
+ fileh.setLevel(logging.DEBUG)
+ fileh.setFormatter(formatter)
+ logger.addHandler(fileh)
+
+ 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)