diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-11-01 10:50:38 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-11-01 10:50:38 -0300 |
commit | 23e9034664edf6b2a01a677c4fa4e6efd880e364 (patch) | |
tree | fc90f154cf81cbaf48dd2d4a738a379591c4e7c7 /src/leap/bitmask/app.py | |
parent | a06b5719f028e619a4b3800fb346ed3c984e4d25 (diff) | |
parent | 80fde752f0bf7946869361f6a77d1952f9339636 (diff) |
Merge branch 'release-0.3.6'
Diffstat (limited to 'src/leap/bitmask/app.py')
-rw-r--r-- | src/leap/bitmask/app.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 40a77075..3bb9c8c3 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -39,7 +39,6 @@ # M:::::::::::~NMMM7???7MMMM:::::::::::::::::::::::NMMMI??I7MMMM:::::::::::::M # M::::::::::::::7MMMMMMM+:::::::::::::::::::::::::::?MMMMMMMZ:::::::::::::::M # (thanks to: http://www.glassgiant.com/ascii/) - import logging import signal import sys @@ -105,9 +104,16 @@ def add_logger_handlers(debug=False, logfile=None): formatter = logging.Formatter(log_format) # Console handler - console = logging.StreamHandler() - console.setLevel(level) - console.setFormatter(formatter) + try: + import coloredlogs + console = coloredlogs.ColoredStreamHandler(level=level) + except ImportError: + console = logging.StreamHandler() + console.setLevel(level) + console.setFormatter(formatter) + using_coloredlog = False + else: + using_coloredlog = True silencer = log_silencer.SelectiveSilencerFilter() console.addFilter(silencer) @@ -131,6 +137,9 @@ def add_logger_handlers(debug=False, logfile=None): logger.addHandler(fileh) logger.debug('File handler plugged!') + if not using_coloredlog: + replace_stdout_stderr_with_logging(logger) + return logger @@ -185,7 +194,6 @@ def main(): BaseConfig.standalone = standalone logger = add_logger_handlers(debug, logfile) - replace_stdout_stderr_with_logging(logger) # And then we import all the other stuff from leap.bitmask.gui import locale_rc |