python: Use format string for logging str(obj).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-10-07 22:34:49 -07:00 committed by Tim Abbott
parent fcd81a8473
commit b45484573e
4 changed files with 5 additions and 7 deletions

View File

@ -94,7 +94,7 @@ def fix_unsubscribed(cursor: CursorWrapper, user_profile: UserProfile) -> None:
rows = cursor.fetchall() rows = cursor.fetchall()
for row in rows: for row in rows:
recipient_ids.append(row[0]) recipient_ids.append(row[0])
logger.info(str(recipient_ids)) logger.info("%s", recipient_ids)
get_timing( get_timing(
"get recipients", "get recipients",

View File

@ -289,9 +289,7 @@ def send_email(
) )
raise EmailNotDeliveredException raise EmailNotDeliveredException
except smtplib.SMTPException as e: except smtplib.SMTPException as e:
logger.exception( logger.exception("Error sending %s email to %s: %s", template, mail.to, e, stack_info=True)
"Error sending %s email to %s: %s", template, mail.to, str(e), stack_info=True
)
raise EmailNotDeliveredException raise EmailNotDeliveredException

View File

@ -958,7 +958,7 @@ class EmbeddedBotWorker(QueueProcessingWorker):
bot_handler=self.get_bot_api_client(user_profile), bot_handler=self.get_bot_api_client(user_profile),
) )
except EmbeddedBotQuitException as e: except EmbeddedBotQuitException as e:
logging.warning(str(e)) logging.warning("%s", e)
@assign_queue("deferred_work") @assign_queue("deferred_work")

View File

@ -1822,12 +1822,12 @@ class SocialAuthMixin(ZulipAuthMixin, ExternalAuthMethod, BaseAuth):
# the flow or the IdP is unreliable and returns a bad http response), # the flow or the IdP is unreliable and returns a bad http response),
# don't throw a 500, just send them back to the # don't throw a 500, just send them back to the
# login page and record the event at the info log level. # login page and record the event at the info log level.
self.logger.info("%s: %s", type(e).__name__, str(e)) self.logger.info("%s: %s", type(e).__name__, e)
return None return None
except SocialAuthBaseException as e: except SocialAuthBaseException as e:
# Other python-social-auth exceptions are likely # Other python-social-auth exceptions are likely
# interesting enough that we should log a warning. # interesting enough that we should log a warning.
self.logger.warning(str(e)) self.logger.warning("%s", e)
return None return None
def should_auto_signup(self) -> bool: def should_auto_signup(self) -> bool: