Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

logging: Pass more format arguments to logging.

Anders Kaseorg4b6d2cf25f6d
diff --git a/analytics/management/commands/update_analytics_counts.py b/analytics/management/commands/update_analytics_counts.py
index 2f664095633..d414a047474 100644
--- a/analytics/management/commands/update_analytics_counts.py
+++ b/analytics/management/commands/update_analytics_counts.py
@@ -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()
diff --git a/zerver/lib/queue.py b/zerver/lib/queue.py
index f132e2a11a3..e5d5489598b 100644
--- a/zerver/lib/queue.py
+++ b/zerver/lib/queue.py
@@ -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:
diff --git a/zerver/management/commands/soft_deactivate_users.py b/zerver/management/commands/soft_deactivate_users.py
index 26481ab1ac0..cf44d80a751 100644
--- a/zerver/management/commands/soft_deactivate_users.py
+++ b/zerver/management/commands/soft_deactivate_users.py
@@ -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")