Skip to content

Commit

Permalink
minimize logs noise
Browse files Browse the repository at this point in the history
  • Loading branch information
fdev31 committed Nov 12, 2023
1 parent 6d88619 commit a0fb5d9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pyprland/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def _callHandler(self, full_name, *params):

for plugin in [self] + list(self.plugins.values()):
if hasattr(plugin, full_name):
self.log.debug("%s.%s%s", plugin.name, full_name, params)
self.log.info("%s.%s%s", plugin.name, full_name, params)
try:
await getattr(plugin, full_name)(*params)
except AssertionError as e:
Expand All @@ -86,6 +86,10 @@ async def _callHandler(self, full_name, *params):
"%s::%s(%s) failed:", plugin.name, full_name, params
)
self.log.exception(e)
break
else:
return False
return True

async def read_events_loop(self):
"Consumes the event loop and calls corresponding handlers"
Expand All @@ -99,9 +103,9 @@ async def read_events_loop(self):
self.log.critical("Reader starved")
return
cmd, params = data.split(">>", 1)
self.log.info("EVT: %s:%s)", cmd, params.strip())
full_name = f"event_{cmd}"

# self.log.debug("[%s] %s", cmd, params.strip())
await self._callHandler(full_name, params)

async def read_command(self, reader, writer) -> None:
Expand Down Expand Up @@ -129,9 +133,8 @@ async def read_command(self, reader, writer) -> None:
# run mako for notifications & uncomment this
# os.system(f"notify-send '{data}'")

self.log.debug("CMD: %s(%s)", full_name, args)

await self._callHandler(full_name, *args)
if not await self._callHandler(full_name, *args):
self.log.warning("No such command: %s", cmd)

async def serve(self):
"Runs the server"
Expand Down

0 comments on commit a0fb5d9

Please sign in to comment.