From 04c0f4472a2d1bd377cc0d4fa94c18e87a4fb13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 5 May 2014 02:15:01 +0200 Subject: [PATCH] log_dialog: display only last 1MB of log, force it plain text --- qubesmanager/log_dialog.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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):