Add a webelem logger

This commit is contained in:
Florian Bruhin 2016-09-07 11:51:23 +02:00
parent c3b80c6b5b
commit 0ff98f568c
4 changed files with 14 additions and 12 deletions

View File

@ -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("<object> without type clicked...")
log.webelem.debug("<object> 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("<object type='{}'> clicked.".format(objtype))
log.webelem.debug("<object type='{}'> 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,

View File

@ -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()

View File

@ -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))):

View File

@ -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