Better logging for ModeManager

This commit is contained in:
Florian Bruhin 2014-04-24 07:44:47 +02:00
parent a82ab6d707
commit b9d845180e

View File

@ -109,10 +109,10 @@ class ModeManager(QObject):
entered: With the new mode name. entered: With the new mode name.
""" """
logging.debug("Switching mode to {}".format(mode)) logging.debug("Switching mode to {}".format(mode))
logging.debug("Mode stack: {}".format(self._mode_stack))
if mode not in self._handlers: if mode not in self._handlers:
raise ValueError("No handler for mode {}".format(mode)) raise ValueError("No handler for mode {}".format(mode))
self._mode_stack.append(mode) self._mode_stack.append(mode)
logging.debug("New mode stack: {}".format(self._mode_stack))
self.entered.emit(mode) self.entered.emit(mode)
def leave(self, mode): def leave(self, mode):
@ -128,6 +128,8 @@ class ModeManager(QObject):
self._mode_stack.remove(mode) self._mode_stack.remove(mode)
except ValueError: except ValueError:
raise ValueError("Mode {} not on mode stack!".format(mode)) raise ValueError("Mode {} not on mode stack!".format(mode))
logging.debug("Leaving mode {}".format(mode))
logging.debug("New mode stack: {}".format(self._mode_stack))
self.left.emit(mode) self.left.emit(mode)
def eventFilter(self, _obj, evt): def eventFilter(self, _obj, evt):