[core] input: add logging for input events

to debug input event issues (which seem to become more frequent), add
some input event logging.

see #336
This commit is contained in:
Tobias Witek 2018-12-03 20:17:18 +01:00
parent 37faef033e
commit 1850ceefdc

View file

@ -5,9 +5,12 @@ import json
import uuid import uuid
import time import time
import select import select
import logging
import threading import threading
import bumblebee.util import bumblebee.util
log = logging.getLogger(__name__)
LEFT_MOUSE = 1 LEFT_MOUSE = 1
MIDDLE_MOUSE = 2 MIDDLE_MOUSE = 2
RIGHT_MOUSE = 3 RIGHT_MOUSE = 3
@ -24,6 +27,7 @@ def read_input(inp):
"""Read i3bar input and execute callbacks""" """Read i3bar input and execute callbacks"""
epoll = select.epoll() epoll = select.epoll()
epoll.register(sys.stdin.fileno(), select.EPOLLIN) epoll.register(sys.stdin.fileno(), select.EPOLLIN)
log.debug("starting click event processing")
while inp.running: while inp.running:
if is_terminated(): if is_terminated():
return return
@ -36,14 +40,18 @@ def read_input(inp):
line = "[" line = "["
while line.startswith("["): while line.startswith("["):
line = sys.stdin.readline().strip(",").strip() line = sys.stdin.readline().strip(",").strip()
log.debug("new event: {}".format(line))
inp.has_event = True inp.has_event = True
try: try:
event = json.loads(line) event = json.loads(line)
if "instance" in event: if "instance" in event:
inp.callback(event) inp.callback(event)
inp.redraw() inp.redraw()
except ValueError: else:
pass log.debug("field 'instance' missing in input, not processing the event")
except ValueError as e:
log.debug("failed to parse event: {}".format(e))
log.debug("exiting click event processing")
epoll.unregister(sys.stdin.fileno()) epoll.unregister(sys.stdin.fileno())
epoll.close() epoll.close()
inp.has_event = True inp.has_event = True