diff --git a/swh/journal/cli.py b/swh/journal/cli.py --- a/swh/journal/cli.py +++ b/swh/journal/cli.py @@ -7,6 +7,7 @@ import functools import logging import os +import time from swh.core import config from swh.core.cli import CONTEXT_SETTINGS @@ -93,9 +94,13 @@ try: nb_messages = 0 + last_log_time = 0 while not max_messages or nb_messages < max_messages: nb_messages += client.process(worker_fn) - logger.info('Processed %d messages.' % nb_messages) + if time.time() - last_log_time >= 60: + # Log at most once per minute. + logger.info('Processed %d messages.' % nb_messages) + last_log_time = time.time() except KeyboardInterrupt: ctx.exit(0) else: @@ -184,9 +189,13 @@ try: nb_messages = 0 + last_log_time = 0 while True: nb_messages += client.process(worker_fn) - logger.info('Processed %d messages.' % nb_messages) + if time.time() - last_log_time >= 60: + # Log at most once per minute. + logger.info('Processed %d messages.' % nb_messages) + last_log_time = time.time() except KeyboardInterrupt: ctx.exit(0) else: