logging: Pass more format arguments to logging.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-06-13 19:27:02 -07:00 committed by Tim Abbott
parent 1a3441dbf5
commit 4b6d2cf25f
3 changed files with 15 additions and 12 deletions

View File

@ -71,7 +71,7 @@ class Command(BaseCommand):
else:
stats = list(COUNT_STATS.values())
logger.info(f"Starting updating analytics counts through {fill_to_time}")
logger.info("Starting updating analytics counts through %s", fill_to_time)
if options['verbose']:
start = time.time()
last = start
@ -85,7 +85,7 @@ class Command(BaseCommand):
if options['verbose']:
print("Finished updating analytics counts through %s in %.3fs" %
(fill_to_time, time.time() - start))
logger.info(f"Finished updating analytics counts through {fill_to_time}")
logger.info("Finished updating analytics counts through %s", fill_to_time)
if settings.PUSH_NOTIFICATION_BOUNCER_URL and settings.SUBMIT_USAGE_STATISTICS:
send_analytics_to_remote_server()

View File

@ -243,20 +243,23 @@ class TornadoQueueClient(SimpleQueueClient):
reason: Exception) -> None:
self._connection_failure_count += 1
retry_secs = self.CONNECTION_RETRY_SECS
message = ("TornadoQueueClient couldn't connect to RabbitMQ, retrying in %d secs..."
% (retry_secs,))
if self._connection_failure_count > self.CONNECTION_FAILURES_BEFORE_NOTIFY:
self.log.critical(message)
else:
self.log.warning(message)
self.log.log(
logging.CRITICAL
if self._connection_failure_count > self.CONNECTION_FAILURES_BEFORE_NOTIFY
else logging.WARNING,
"TornadoQueueClient couldn't connect to RabbitMQ, retrying in %d secs...",
retry_secs,
)
ioloop.IOLoop.instance().call_later(retry_secs, self._reconnect)
def _on_connection_closed(self, connection: pika.connection.Connection,
reason: Exception) -> None:
self._connection_failure_count = 1
retry_secs = self.CONNECTION_RETRY_SECS
self.log.warning("TornadoQueueClient lost connection to RabbitMQ, reconnecting in %d secs..."
% (retry_secs,))
self.log.warning(
"TornadoQueueClient lost connection to RabbitMQ, reconnecting in %d secs...",
retry_secs,
)
ioloop.IOLoop.instance().call_later(retry_secs, self._reconnect)
def _on_open(self, connection: pika.connection.Connection) -> None:

View File

@ -73,7 +73,7 @@ class Command(ZulipBaseCommand):
users_to_activate = get_users_from_emails(user_emails, filter_kwargs)
users_activated = do_soft_activate_users(users_to_activate)
logger.info('Soft Reactivated %d user(s)' % (len(users_activated),))
logger.info('Soft Reactivated %d user(s)', len(users_activated))
elif deactivate:
if user_emails:
@ -83,7 +83,7 @@ class Command(ZulipBaseCommand):
else:
users_deactivated = do_auto_soft_deactivate_users(int(options['inactive_for']),
realm)
logger.info('Soft Deactivated %d user(s)' % (len(users_deactivated),))
logger.info('Soft Deactivated %d user(s)', len(users_deactivated))
else:
self.print_help("./manage.py", "soft_deactivate_users")