Skip to content

Commit

Permalink
track errors in logger
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmiglio committed Nov 23, 2022
1 parent 433f29d commit c4f4d44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pyclashbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,13 @@ def main_gui():
# enable the start button and configuration after the thread is stopped
for key in disable_keys:
window[key].update(disabled=False)
# reset the communication queue and logger
statistics_q = Queue()
logger = Logger(statistics_q, console_log=console_log, timed=False)
thread = None
if thread.logger.errored:
window["Stop"].update(disabled=True)
else:
# reset the communication queue and logger
statistics_q = Queue()
logger = Logger(statistics_q, console_log=console_log, timed=False)
thread = None

update_layout(window, logger)

Expand Down
4 changes: 4 additions & 0 deletions pyclashbot/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def __init__(
self.war_battles_fought = 0
self.current_status = "Idle"

# track errored logger
self.errored = False

# write initial values to queue
self._update_queue()

Expand Down Expand Up @@ -243,6 +246,7 @@ def error(self, message: str):
Args:
message (str): error message
"""
self.errored = True
self.current_status = f"Error: {message}"

@_updates_log
Expand Down

0 comments on commit c4f4d44

Please sign in to comment.