diff --git a/qutebrowser/browser/signalfilter.py b/qutebrowser/browser/signalfilter.py index 6791fd797..e65078a01 100644 --- a/qutebrowser/browser/signalfilter.py +++ b/qutebrowser/browser/signalfilter.py @@ -70,9 +70,6 @@ class SignalFilter(QObject): """ sender = self.sender() log_signal = not signal.signal.startswith('2cur_progress') - if log_signal: - logging.debug("signal {} (tab {})".format( - dbg_signal(signal, args), self._tabs.indexOf(sender))) if not isinstance(sender, WebView): # BUG? This should never happen, but it does regularely... logging.warn("Got signal {} by {} which is no tab!".format( @@ -80,8 +77,10 @@ class SignalFilter(QObject): return if self._tabs.currentWidget() == sender: if log_signal: - logging.debug(" emitting") + logging.debug("emitting: {} (tab {})".format( + dbg_signal(signal, args), self._tabs.indexOf(sender))) signal.emit(*args) else: if log_signal: - logging.debug(" ignoring") + logging.debug("ignoring: {} (tab {})".format( + dbg_signal(signal, args), self._tabs.indexOf(sender))) diff --git a/qutebrowser/test/utils/test_signal.py b/qutebrowser/test/utils/test_signal.py index e8ea8d1ad..f5698993e 100644 --- a/qutebrowser/test/utils/test_signal.py +++ b/qutebrowser/test/utils/test_signal.py @@ -47,6 +47,15 @@ class TestDebug(TestCase): self.assertEqual(sigutils.dbg_signal(self.signal, [23, 42]), 'fake(23, 42)') + def test_dbg_signal_eliding(self): + self.assertEqual(sigutils.dbg_signal(self.signal, + [12345678901234567890123]), + 'fake(1234567890123456789\u2026)') + + def test_dbg_signal_newline(self): + self.assertEqual(sigutils.dbg_signal(self.signal, ['foo\nbar']), + 'fake(foo bar)') + if __name__ == '__main__': unittest.main() diff --git a/qutebrowser/utils/signals.py b/qutebrowser/utils/signals.py index 253343787..6a45aadad 100644 --- a/qutebrowser/utils/signals.py +++ b/qutebrowser/utils/signals.py @@ -19,6 +19,8 @@ import re +from qutebrowser.utils.misc import elide + def signal_name(sig): """Get a cleaned up name of a signal. @@ -43,4 +45,5 @@ def dbg_signal(sig, args): Return: A human-readable string representation of signal/args. """ - return '{}({})'.format(signal_name(sig), ', '.join(map(str, args))) + argstr = ', '.join([elide(str(a).replace('\n', ' '), 20) for a in args]) + return '{}({})'.format(signal_name(sig), argstr)