diff --git a/atxm/machine.py b/atxm/machine.py index cc63b1c..6538ec5 100644 --- a/atxm/machine.py +++ b/atxm/machine.py @@ -94,6 +94,15 @@ class _Machine(StateMachine): FixedRateSpeedUp, ] + class LogObserver: + """StateMachine observer for logging information about state/transitions.""" + def __init__(self): + self.log = log + + def on_transition(self, source, target): + if source.id != target.id: + self.log.debug(f"[transition] {source.name} --> {target.name}") + def __init__( self, w3: Web3, @@ -121,6 +130,8 @@ def __init__( super().__init__() + self.add_observer(_Machine.LogObserver()) + @property def _busy(self) -> bool: """Returns True if the machine is busy.""" @@ -144,7 +155,7 @@ def _handle_errors(self, *args, **kwargs): # State Transitions @_transition_to_paused.before def _enter_pause_mode(self): - self.log.warn("[pause] pause activated") + self.log.info("[pause] pause mode activated") return @_PAUSED.enter @@ -192,7 +203,6 @@ def _process_busy(self): if self._tx_tracker.pending: # There is an active transaction self.__handle_active_transaction() - elif self._tx_tracker.queue: # There is no active transaction # and there are queued transactions