From 0ff98f568c99e5226c6b1496845fe639b9f8fbb7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 7 Sep 2016 11:51:23 +0200 Subject: [PATCH] Add a webelem logger --- qutebrowser/browser/webelem.py | 10 +++++----- qutebrowser/browser/webengine/webengineelem.py | 4 ++-- qutebrowser/browser/webkit/webkitelem.py | 8 ++++---- qutebrowser/utils/log.py | 4 +++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py index 6adc5e69f..bac69d39e 100644 --- a/qutebrowser/browser/webelem.py +++ b/qutebrowser/browser/webelem.py @@ -214,14 +214,14 @@ class AbstractWebElement(collections.abc.MutableMapping): def _is_editable_object(self): """Check if an object-element is editable.""" if 'type' not in self: - log.webview.debug(" without type clicked...") + log.webelem.debug(" without type clicked...") return False objtype = self['type'].lower() if objtype.startswith('application/') or 'classid' in self: # Let's hope flash/java stuff has an application/* mimetype OR # at least a classid attribute. Oh, and let's hope images/... # DON'T have a classid attribute. HTML sucks. - log.webview.debug(" clicked.".format(objtype)) + log.webelem.debug(" clicked.".format(objtype)) return config.get('input', 'insert-mode-on-plugins') else: # Image/Audio/... @@ -270,7 +270,7 @@ class AbstractWebElement(collections.abc.MutableMapping): True if we should switch to insert mode, False otherwise. """ roles = ('combobox', 'textbox') - log.misc.debug("Checking if element is editable: {}".format( + log.webelem.debug("Checking if element is editable: {}".format( repr(self))) tag = self.tag_name() if self.is_content_editable() and self.is_writable(): @@ -361,8 +361,8 @@ class AbstractWebElement(collections.abc.MutableMapping): pos = self._mouse_pos() - log.hints.debug("Sending fake click to {!r} at position {} with " - "target {}".format(self, pos, click_target)) + log.webelem.debug("Sending fake click to {!r} at position {} with " + "target {}".format(self, pos, click_target)) if click_target in [usertypes.ClickTarget.tab, usertypes.ClickTarget.tab_bg, diff --git a/qutebrowser/browser/webengine/webengineelem.py b/qutebrowser/browser/webengine/webengineelem.py index 4878e5de4..afe9665fa 100644 --- a/qutebrowser/browser/webengine/webengineelem.py +++ b/qutebrowser/browser/webengine/webengineelem.py @@ -111,7 +111,7 @@ class WebEngineElement(webelem.AbstractWebElement): def insert_text(self, text): if not self.is_editable(strict=True): raise webelem.Error("Element is not editable!") - log.misc.debug("Inserting text into element {!r}".format(self)) + log.webelem.debug("Inserting text into element {!r}".format(self)) js_code = javascript.assemble('webelem', 'insert_text', self._id, text) self._tab.run_js_async(js_code) @@ -159,7 +159,7 @@ class WebEngineElement(webelem.AbstractWebElement): # rect.translate(frame.geometry().topLeft()) # frame = frame.parentFrame() return rect - log.webview.debug("Couldn't find rectangle for {!r} ({})".format( + log.webelem.debug("Couldn't find rectangle for {!r} ({})".format( self, rects)) return QRect() diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py index ebe62afbd..ad5156bab 100644 --- a/qutebrowser/browser/webkit/webkitelem.py +++ b/qutebrowser/browser/webkit/webkitelem.py @@ -126,10 +126,10 @@ class WebKitElement(webelem.AbstractWebElement): def set_text(self, text, *, use_js=False): self._check_vanished() if self.is_content_editable() or not use_js: - log.misc.debug("Filling {!r} via set_text.".format(self)) + log.webelem.debug("Filling {!r} via set_text.".format(self)) self._elem.setPlainText(text) else: - log.misc.debug("Filling {!r} via javascript.".format(self)) + log.webelem.debug("Filling {!r} via javascript.".format(self)) text = javascript.string_escape(text) self._elem.evaluateJavaScript("this.value='{}'".format(text)) @@ -137,7 +137,7 @@ class WebKitElement(webelem.AbstractWebElement): self._check_vanished() if not self.is_editable(strict=True): raise webelem.Error("Element is not editable!") - log.misc.debug("Inserting text into element {!r}".format(self)) + log.webelem.debug("Inserting text into element {!r}".format(self)) self._elem.evaluateJavaScript(""" var text = "{}"; var event = document.createEvent("TextEvent"); @@ -163,7 +163,7 @@ class WebKitElement(webelem.AbstractWebElement): return None text = utils.compact_text(self._elem.toOuterXml(), 500) - log.hints.vdebug("Client rectangles of element '{}': {}".format( + log.webelem.vdebug("Client rectangles of element '{}': {}".format( text, rects)) for i in range(int(rects.get("length", 0))): diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 18b4e2dc9..c88df8a38 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -93,7 +93,8 @@ LOGGER_NAMES = [ 'mouse', 'procs', 'hints', 'keyboard', 'commands', 'signals', 'downloads', 'js', 'qt', 'rfc6266', 'ipc', 'shlexer', - 'save', 'message', 'config', 'sessions' + 'save', 'message', 'config', 'sessions', + 'webelem' ] @@ -137,6 +138,7 @@ save = logging.getLogger('save') message = logging.getLogger('message') config = logging.getLogger('config') sessions = logging.getLogger('sessions') +webelem = logging.getLogger('webelem') ram_handler = None