From c2ece2903e825ae730217c00ff3191202920f8c3 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Mon, 12 Aug 2013 16:36:33 -0300 Subject: Add filter option to the logger window. Closes #3407. --- src/leap/bitmask/gui/loggerwindow.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/gui/loggerwindow.py b/src/leap/bitmask/gui/loggerwindow.py index 981bf65d..9b4ba55d 100644 --- a/src/leap/bitmask/gui/loggerwindow.py +++ b/src/leap/bitmask/gui/loggerwindow.py @@ -56,6 +56,10 @@ class LoggerWindow(QtGui.QDialog): self.ui.btnWarning.toggled.connect(self._load_history), self.ui.btnError.toggled.connect(self._load_history), self.ui.btnCritical.toggled.connect(self._load_history) + self.ui.leFilterBy.textEdited.connect(self._filter_by) + self.ui.cbCaseInsensitive.stateChanged.connect(self._load_history) + + self._current_filter = "" # Load logging history and connect logger with the widget self._logging_handler = handler @@ -95,7 +99,14 @@ class LoggerWindow(QtGui.QDialog): close_tag = "" message = open_tag + message + close_tag - self.ui.txtLogHistory.append(message) + filter_by = self._current_filter + msg = message + if self.ui.cbCaseInsensitive.isChecked(): + msg = msg.upper() + filter_by = filter_by.upper() + + if msg.find(filter_by) != -1: + self.ui.txtLogHistory.append(message) def _load_history(self): """ @@ -120,6 +131,16 @@ class LoggerWindow(QtGui.QDialog): logging.CRITICAL: self.ui.btnCritical.isChecked() } + def _filter_by(self, text): + """ + Sets the text to use for filtering logs in the log window. + + :param text: the text to compare with the logs when filtering. + :type text: str + """ + self._current_filter = text + self._load_history() + def _save_log_to_file(self): """ Lets the user save the current log to a file -- cgit v1.2.3