some logging rework

This commit is contained in:
fdev31 2023-07-30 00:55:30 +02:00
parent 6d4834989e
commit 9c15ce42e2
2 changed files with 3 additions and 8 deletions

View file

@ -65,9 +65,9 @@ class Pyprland:
async def _callHandler(self, full_name, *params): async def _callHandler(self, full_name, *params):
"Call an event handler with params" "Call an event handler with params"
have_listeners = False
for plugin in [self] + list(self.plugins.values()): for plugin in [self] + list(self.plugins.values()):
if hasattr(plugin, full_name): if hasattr(plugin, full_name):
self.log.debug("%s.%s%s", plugin.name, full_name, params)
try: try:
await getattr(plugin, full_name)(*params) await getattr(plugin, full_name)(*params)
except Exception as e: # pylint: disable=W0718 except Exception as e: # pylint: disable=W0718
@ -75,10 +75,6 @@ class Pyprland:
"%s::%s(%s) failed:", plugin.name, full_name, params "%s::%s(%s) failed:", plugin.name, full_name, params
) )
self.log.exception(e) self.log.exception(e)
else:
have_listeners = True
if have_listeners:
self.log.debug("%s%s", full_name, params)
async def read_events_loop(self): async def read_events_loop(self):
"Consumes the event loop and calls corresponding handlers" "Consumes the event loop and calls corresponding handlers"

View file

@ -21,7 +21,7 @@ async def get_event_stream():
async def hyprctlJSON(command) -> list[dict[str, Any]] | dict[str, Any]: async def hyprctlJSON(command) -> list[dict[str, Any]] | dict[str, Any]:
"""Run an IPC command and return the JSON output.""" """Run an IPC command and return the JSON output."""
log.debug("JS>> %s", command) log.debug(command)
try: try:
ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL) ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL)
except FileNotFoundError as e: except FileNotFoundError as e:
@ -48,7 +48,7 @@ def _format_command(command_list, default_base_command):
async def hyprctl(command, base_command="dispatch") -> bool: async def hyprctl(command, base_command="dispatch") -> bool:
"""Run an IPC command. Returns success value.""" """Run an IPC command. Returns success value."""
log.debug("JS>> %s", command) log.debug(command)
try: try:
ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL) ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL)
except FileNotFoundError as e: except FileNotFoundError as e:
@ -65,7 +65,6 @@ async def hyprctl(command, base_command="dispatch") -> bool:
resp = await ctl_reader.read(100) resp = await ctl_reader.read(100)
ctl_writer.close() ctl_writer.close()
await ctl_writer.wait_closed() await ctl_writer.wait_closed()
log.debug("<<JS %s", resp)
r: bool = resp == b"ok" * (len(resp) // 2) r: bool = resp == b"ok" * (len(resp) // 2)
if not r: if not r:
log.error("FAILED %s", resp) log.error("FAILED %s", resp)