-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from chStaiger/develop
v0.2.2
- Loading branch information
Showing
18 changed files
with
279 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Logging tab.""" | ||
|
||
import logging | ||
import sys | ||
|
||
import PyQt6 | ||
|
||
from ibridgesgui.config import CONFIG_DIR | ||
from ibridgesgui.gui_utils import UI_FILE_DIR | ||
from ibridgesgui.ui_files.tabLogging import Ui_tabLogging | ||
|
||
|
||
class QTextEditLogger(logging.Handler, PyQt6.QtCore.QObject): | ||
"""Logging in a Qt text browser.""" | ||
|
||
append_plain_text = PyQt6.QtCore.pyqtSignal(str) | ||
|
||
def __init__(self, text_browser): | ||
"""Initialise.""" | ||
super().__init__() | ||
PyQt6.QtCore.QObject.__init__(self) | ||
self.widget = text_browser | ||
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) | ||
|
||
|
||
class LogViewer(PyQt6.QtWidgets.QWidget, Ui_tabLogging): | ||
"""Set iBridges logging in GUI.""" | ||
|
||
def __init__(self, logger): | ||
"""Initialise the tab.""" | ||
super().__init__() | ||
if getattr(sys, "frozen", False): | ||
super().setupUi(self) | ||
else: | ||
PyQt6.uic.loadUi(UI_FILE_DIR / "tabLogging.ui", self) | ||
|
||
self.logger = logger | ||
self.log_label.setText(str(CONFIG_DIR)) | ||
self.log_text = QTextEditLogger(self.log_browser) | ||
self.log_text.setFormatter( | ||
logging.Formatter( | ||
'%(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s')) | ||
self.logger.addHandler(self.log_text) | ||
self.logger.setLevel(logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.