Skip to content

Commit

Permalink
refactor speed formatting in logging for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizard1209 committed Dec 15, 2024
1 parent be7b3e7 commit 5ca8405
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dipdup/dipdup.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,15 @@ def _log_status(self) -> None:
_logger.info(msg)
return

levels_speed, objects_speed = int(metrics.levels_nonempty_speed), int(metrics.objects_speed)
levels_speed, objects_speed = float(metrics.levels_nonempty_speed), float(metrics.objects_speed)
msg = 'last mile' if metrics.synchronized_at else 'indexing'
msg += f': {progress:5.1f}% done, {left} levels left'

# NOTE: Resulting message is about 80 chars with the current logging format
msg += ' ' * (48 - len(msg))
msg += f' {levels_speed:5} L {objects_speed:5} O'
def fmt(speed):
return ' 0' if speed < 0.1 else f'{speed:5.{0 if speed >= 1 else 1}f}'
msg += f' {fmt(levels_speed)} L {fmt(objects_speed)} O'
_logger.info(msg)

async def _apply_filters(self, index: TezosOperationsIndex) -> None:
Expand Down

0 comments on commit 5ca8405

Please sign in to comment.