Skip to content

Commit

Permalink
Merge pull request #219 from chStaiger/develop
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
chStaiger authored Jun 28, 2024
2 parents 473cbb4 + f1b9492 commit b57adf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions ibridgesgui/logviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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")
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
]
Expand Down

0 comments on commit b57adf7

Please sign in to comment.