From 6d3c7eddc8899b8dce54d41ac546db0521cca33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Mand=C3=A1k?= Date: Fri, 25 Sep 2015 19:12:05 +0200 Subject: [PATCH] Module: More detailed logs for clickevents as suggested by @teto in #231. --- i3pystatus/core/modules.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/i3pystatus/core/modules.py b/i3pystatus/core/modules.py index 0c069c4..d1fa235 100644 --- a/i3pystatus/core/modules.py +++ b/i3pystatus/core/modules.py @@ -75,6 +75,11 @@ class Module(SettingsBase): ) """ + def log_event(name, button, cb, args, action): + msg = "{}: button={}, cb='{}', args={}, type='{}'".format( + name, button, cb, args, action) + self.logger.debug(msg) + def split_callback_and_args(cb): if isinstance(cb, list): return cb[0], cb[1:] @@ -91,23 +96,25 @@ class Module(SettingsBase): elif button == 5: # mouse wheel down cb = self.on_downscroll else: - self.logger.info("Button '%d' not handled yet." % (button)) + log_event(self.__name__, button, None, None, "Unhandled button") return False if not cb: - self.logger.info("no cb attached") + log_event(self.__name__, button, None, None, "No callback attached") return False else: cb, args = split_callback_and_args(cb) - self.logger.debug("cb=%s args=%s" % (cb, args)) if callable(cb): cb(self, *args) + log_event(self.__name__, button, cb, args, "Python callback") elif hasattr(self, cb): if cb is not "run": getattr(self, cb)(*args) + log_event(self.__name__, button, cb, args, "Member callback") else: execute(cb, detach=True) + log_event(self.__name__, button, cb, args, "External command") return True def move(self, position):