Skip to content

Commit

Permalink
some logging rework
Browse files Browse the repository at this point in the history
  • Loading branch information
fdev31 committed Jul 29, 2023
1 parent 6d48349 commit 9c15ce4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 1 addition & 5 deletions pyprland/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,16 @@ async def load_config(self, init=True):
async def _callHandler(self, full_name, *params):
"Call an event handler with params"

have_listeners = False
for plugin in [self] + list(self.plugins.values()):
if hasattr(plugin, full_name):
self.log.debug("%s.%s%s", plugin.name, full_name, params)
try:
await getattr(plugin, full_name)(*params)
except Exception as e: # pylint: disable=W0718
self.log.warning(
"%s::%s(%s) failed:", plugin.name, full_name, params
)
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):
"Consumes the event loop and calls corresponding handlers"
Expand Down
5 changes: 2 additions & 3 deletions pyprland/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def get_event_stream():

async def hyprctlJSON(command) -> list[dict[str, Any]] | dict[str, Any]:
"""Run an IPC command and return the JSON output."""
log.debug("JS>> %s", command)
log.debug(command)
try:
ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL)
except FileNotFoundError as e:
Expand All @@ -48,7 +48,7 @@ def _format_command(command_list, default_base_command):

async def hyprctl(command, base_command="dispatch") -> bool:
"""Run an IPC command. Returns success value."""
log.debug("JS>> %s", command)
log.debug(command)
try:
ctl_reader, ctl_writer = await asyncio.open_unix_connection(HYPRCTL)
except FileNotFoundError as e:
Expand All @@ -65,7 +65,6 @@ async def hyprctl(command, base_command="dispatch") -> bool:
resp = await ctl_reader.read(100)
ctl_writer.close()
await ctl_writer.wait_closed()
log.debug("<<JS %s", resp)
r: bool = resp == b"ok" * (len(resp) // 2)
if not r:
log.error("FAILED %s", resp)
Expand Down

0 comments on commit 9c15ce4

Please sign in to comment.