From 9b9063b7d1450e30ec66b8b7323a22d9e392a51a Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Fri, 19 Jun 2020 17:09:27 +0100 Subject: [PATCH] Fix logging --- pype/modules/logging/gui/models.py | 8 +++----- pype/modules/logging/tray/logging_module.py | 15 +++++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pype/modules/logging/gui/models.py b/pype/modules/logging/gui/models.py index 484fd6dc69..945b76152b 100644 --- a/pype/modules/logging/gui/models.py +++ b/pype/modules/logging/gui/models.py @@ -1,8 +1,7 @@ -import os import collections from Qt import QtCore from pype.api import Logger -from pypeapp.lib.log import _bootstrap_mongo_log +from pypeapp.lib.log import _bootstrap_mongo_log, COLLECTION log = Logger().get_logger("LogModel", "LoggingModule") @@ -41,11 +40,10 @@ class LogModel(QtCore.QAbstractItemModel): super(LogModel, self).__init__(parent) self._root_node = Node() - collection = os.environ.get('PYPE_LOG_MONGO_COL') database = _bootstrap_mongo_log() self.dbcon = None - if collection in database.list_collection_names(): - self.dbcon = database[collection] + if COLLECTION in database.list_collection_names(): + self.dbcon = database[COLLECTION] def add_log(self, log): node = Node(log) diff --git a/pype/modules/logging/tray/logging_module.py b/pype/modules/logging/tray/logging_module.py index 087a51f322..9b26d5d9bf 100644 --- a/pype/modules/logging/tray/logging_module.py +++ b/pype/modules/logging/tray/logging_module.py @@ -1,20 +1,23 @@ from Qt import QtWidgets - from pype.api import Logger - from ..gui.app import LogsWindow -log = Logger().get_logger("LoggingModule", "logging") - class LoggingModule: def __init__(self, main_parent=None, parent=None): self.parent = parent + self.log = Logger().get_logger(self.__class__.__name__, "logging") - self.window = LogsWindow() + try: + self.window = LogsWindow() + self.tray_menu = self._tray_menu + except Exception: + self.log.warning( + "Couldn't set Logging GUI due to error.", exc_info=True + ) # Definition of Tray menu - def tray_menu(self, parent_menu): + def _tray_menu(self, parent_menu): # Menu for Tray App menu = QtWidgets.QMenu('Logging', parent_menu) # menu.setProperty('submenu', 'on')