From fd7237161ba02d5c56c4377e976ee0fcfe29467a Mon Sep 17 00:00:00 2001 From: Adam Saudagar Date: Thu, 3 Feb 2022 05:51:31 +0530 Subject: [PATCH] added few debug logs for engine --- fishy/engine/common/IEngine.py | 11 ++++++++--- fishy/engine/fullautofisher/engine.py | 1 + fishy/engine/semifisher/engine.py | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fishy/engine/common/IEngine.py b/fishy/engine/common/IEngine.py index 2d5338a..b101d4d 100644 --- a/fishy/engine/common/IEngine.py +++ b/fishy/engine/common/IEngine.py @@ -21,6 +21,7 @@ class IEngine: self.state = 0 self.window = None self.thread = None + self.name = "default" @property def gui(self): @@ -46,6 +47,7 @@ class IEngine: def join(self): if self.thread: + logging.debug(f"waiting for {self.name} engine") self.thread.join() def turn_off(self): @@ -54,23 +56,26 @@ class IEngine: its the responsibility of the thread to shut turn itself off """ if self.state == 1: - logging.info("turning off...") + logging.debug(f"sending turn off signal to {self.name} engine") self.state = 2 else: - logging.error("engine already signaled to turn off") + logging.debug(f"{self.name} engine already signaled to turn off ") # todo: implement force turn off on repeated calls # noinspection PyBroadException def _crash_safe(self): - self.window = WindowClient(color=cv2.COLOR_RGB2GRAY, show_name="fishy debug") + logging.debug(f"starting {self.name} engine thread") + self.window = WindowClient(color=cv2.COLOR_RGB2GRAY, show_name=f"{self.name} debug") self.gui.bot_started(True) try: self.run() except Exception: + logging.error(f"Unhandled exception occurred while running {self.name} engine") print_exc() self.state = 0 self.gui.bot_started(False) self.window.destroy() + logging.debug(f"{self.name} engine thread safely exiting") def run(self): raise NotImplementedError diff --git a/fishy/engine/fullautofisher/engine.py b/fishy/engine/fullautofisher/engine.py index ac9789b..83ccd52 100644 --- a/fishy/engine/fullautofisher/engine.py +++ b/fishy/engine/fullautofisher/engine.py @@ -30,6 +30,7 @@ class FullAuto(IEngine): from fishy.engine.fullautofisher.test import Test super().__init__(gui_ref) + self.name = "FullAuto" self._curr_rotate_y = 0 self.fisher = SemiFisherEngine(None) diff --git a/fishy/engine/semifisher/engine.py b/fishy/engine/semifisher/engine.py index e514e35..5852c95 100644 --- a/fishy/engine/semifisher/engine.py +++ b/fishy/engine/semifisher/engine.py @@ -21,6 +21,7 @@ class SemiFisherEngine(IEngine): def __init__(self, gui_ref: Optional['Callable[[], GUI]']): super().__init__(gui_ref) self.window = None + self.name = "SemiFisher" def run(self): """