diff --git a/ibridgesgui/logviewer.py b/ibridgesgui/logviewer.py index f3e06efd..ef1f6a7a 100644 --- a/ibridgesgui/logviewer.py +++ b/ibridgesgui/logviewer.py @@ -10,23 +10,23 @@ from ibridgesgui.ui_files.tabLogging import Ui_tabLogging -class QTextEditLogger(logging.Handler, PyQt6.QtCore.QObject): - """Logging in a Qt text browser.""" +class QPlainTextEditLogger(logging.Handler, PyQt6.QtCore.QObject): + """A thread safe log handler.""" append_plain_text = PyQt6.QtCore.pyqtSignal(str) - def __init__(self, text_browser): - """Initialise.""" + def __init__(self, widget: PyQt6.QtWidgets.QPlainTextEdit): + """Initialize the log handler.""" super().__init__() PyQt6.QtCore.QObject.__init__(self) - self.widget = text_browser + self.widget = widget self.widget.setReadOnly(True) self.append_plain_text.connect(self.widget.insertPlainText) - def emit(self, record): - """Emit when new logging accurs.""" - msg = self.format(record) + "\n" - self.append_plain_text.emit(msg) + def emit(self, record: logging.LogRecord): + """Pass `record` to all connected slots.""" + msg = self.format(record)+"\n" + self.append_plainText.emit(msg) class LogViewer(PyQt6.QtWidgets.QWidget, Ui_tabLogging): @@ -42,7 +42,7 @@ def __init__(self, logger): self.logger = logger self.log_label.setText(str(CONFIG_DIR)) - self.log_text = QTextEditLogger(self.log_browser) + self.log_text = QPlainTextEditLogger(self.log_browser) self.log_text.setFormatter( logging.Formatter("%(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s") ) diff --git a/pyproject.toml b/pyproject.toml index 69fc986a..3604c770 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ classifiers = [ dependencies = [ "PyQt6>=6.4.2", - "ibridges>=0.2.3", + "ibridges>=1.0.0", "setproctitle==1.3.3", "importlib-resources;python_version<='3.10'", ]