summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/leap/gui/loggerwindow.py24
-rw-r--r--src/leap/util/leap_log_handler.py17
2 files changed, 19 insertions, 22 deletions
diff --git a/src/leap/gui/loggerwindow.py b/src/leap/gui/loggerwindow.py
index 4d24a7d8..fcbdbf19 100644
--- a/src/leap/gui/loggerwindow.py
+++ b/src/leap/gui/loggerwindow.py
@@ -76,11 +76,23 @@ class LoggerWindow(QtGui.QDialog):
the record contains the LogRecord of the logging module,
the message contains the formatted message for the log.
"""
- level = log[LeapLogHandler.RECORD_KEY].levelname
+ html_style = {
+ logging.DEBUG: "background: #CDFFFF;",
+ logging.INFO: "background: white;",
+ logging.WARNING: "background: #FFFF66;",
+ logging.ERROR: "background: red; color: white;",
+ logging.CRITICAL: "background: red; color: white; font: bold;"
+ }
+ level = log[LeapLogHandler.RECORD_KEY].levelno
message = log[LeapLogHandler.MESSAGE_KEY]
message = message.replace('\n', '<br>\n')
if self._logs_to_display[level]:
+ open_tag = "<tr style='" + html_style[level] + "'>"
+ open_tag += "<td width='100%' style='padding: 5px;'>"
+ close_tag = "</td></tr>"
+ message = open_tag + message + close_tag
+
self.ui.txtLogHistory.append(message)
def _load_history(self):
@@ -99,11 +111,11 @@ class LoggerWindow(QtGui.QDialog):
Sets the logs_to_display dict getting the toggled options from the ui
"""
self._logs_to_display = {
- 'DEBUG': self.ui.btnDebug.isChecked(),
- 'INFO': self.ui.btnInfo.isChecked(),
- 'WARNING': self.ui.btnWarning.isChecked(),
- 'ERROR': self.ui.btnError.isChecked(),
- 'CRITICAL': self.ui.btnCritical.isChecked()
+ logging.DEBUG: self.ui.btnDebug.isChecked(),
+ logging.INFO: self.ui.btnInfo.isChecked(),
+ logging.WARNING: self.ui.btnWarning.isChecked(),
+ logging.ERROR: self.ui.btnError.isChecked(),
+ logging.CRITICAL: self.ui.btnCritical.isChecked()
}
def _save_log_to_file(self):
diff --git a/src/leap/util/leap_log_handler.py b/src/leap/util/leap_log_handler.py
index 271096d3..9adb21a5 100644
--- a/src/leap/util/leap_log_handler.py
+++ b/src/leap/util/leap_log_handler.py
@@ -52,22 +52,7 @@ class LogHandler(logging.Handler):
:param logging_level: the debug level to define the color.
:type logging_level: str.
"""
- html_style = {
- 'DEBUG': "color: blue",
- 'INFO': "color: black",
- 'WARNING': "color: black; background: yellow;",
- 'ERROR': "color: red",
- 'CRITICAL': "color: red; font-weight: bold;"
- }
-
- style_open = "<span style='" + html_style[logging_level] + "'>"
- style_close = "</span>"
- time = "%(asctime)s"
- name = style_open + "%(name)s"
- level = "%(levelname)s"
- message = "%(message)s" + style_close
- format_attrs = [time, name, level, message]
- log_format = ' - '.join(format_attrs)
+ log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
formatter = logging.Formatter(log_format)
return formatter