diff --git a/qubesmanager/log_dialog.py b/qubesmanager/log_dialog.py index 4603bf2..6d8e18a 100644 --- a/qubesmanager/log_dialog.py +++ b/qubesmanager/log_dialog.py @@ -33,6 +33,8 @@ import qubesmanager.resources_rc from ui_logdlg import * +# Display only this size of log +LOG_DISPLAY_SIZE = 1024*1024 class LogDialog(Ui_LogDialog, QDialog): @@ -50,10 +52,17 @@ class LogDialog(Ui_LogDialog, QDialog): self.__init_log_text__() def __init_log_text__(self): + self.displayed_text = "" log = open(self.log_path) - self.displayed_text = log.read() + log.seek(0, os.SEEK_END) + if log.tell() > LOG_DISPLAY_SIZE: + self.displayed_text = "(Showing only last %d bytes of file)\n" % LOG_DISPLAY_SIZE + log.seek(-LOG_DISPLAY_SIZE, os.SEEK_END) + else: + log.seek(0, os.SEEK_SET) + self.displayed_text += log.read() log.close() - self.log_text.setText(self.displayed_text) + self.log_text.setPlainText(self.displayed_text) def copy_to_qubes_clipboard_triggered(self):