Skip to content

Commit

Permalink
ML-717: Use logger.debug instead of print. (#249)
Browse files Browse the repository at this point in the history
* ML-717: Use logger.debug instead of print.

* Minor refactoring.
  • Loading branch information
Gal Topper authored Jun 23, 2021
1 parent 640559a commit 1bca512
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions storey/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, recovery_step=None, termination_result_fn=lambda x, y: x if x
self._termination_result_fn = termination_result_fn
self.context = context
self.verbose = context and getattr(context, 'verbose', False)
self.logger = getattr(self.context, 'logger', None) if self.context else None

self._kwargs = kwargs
self._full_event = kwargs.pop('full_event', False)
Expand Down Expand Up @@ -183,14 +184,14 @@ async def _do_downstream(self, event):
event_copy._awaitable_result = awaitable_result
tasks.append(asyncio.get_running_loop().create_task(self._outlets[i]._do_and_recover(event_copy)))
event._awaitable_result = awaitable_result
if self.verbose:
if self.verbose and self.logger:
step_name = type(self).__name__
event_string = self._event_string(event)
print(f'{step_name} -> {type(self._outlets[0]).__name__} | {event_string}')
self.logger.debug(f'{step_name} -> {type(self._outlets[0]).__name__} | {event_string}')
await self._outlets[0]._do_and_recover(event) # Optimization - avoids creating a task for the first outlet.
for i, task in enumerate(tasks, start=1):
if self.verbose:
print(f'{step_name} -> {type(self._outlets[i]).__name__} | {event_string}')
if self.verbose and self.logger:
self.logger.debug(f'{step_name} -> {type(self._outlets[i]).__name__} | {event_string}')
await task

def _get_event_or_body(self, event):
Expand Down

0 comments on commit 1bca512

Please sign in to comment.