summaryrefslogtreecommitdiff
path: root/src/leap/app.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-05 07:42:10 +0900
committerkali <kali@leap.se>2012-09-05 07:42:10 +0900
commita2804c3de1470db98d8c6aa8a01e2de1aa1718a1 (patch)
tree3743e172e4b7a1e0a2b0650d95950149f66e9ec3 /src/leap/app.py
parent6ef92e257ce1e605194cb26ff6cb804c7d2c3418 (diff)
app wide logging handler
Diffstat (limited to 'src/leap/app.py')
-rw-r--r--src/leap/app.py25
1 files changed, 17 insertions, 8 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)