From 6618cec9db5ab8c4885dd7469ef5ce303e5bed7e Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 15 Nov 2019 17:24:01 -0800 Subject: [PATCH] logging: Switch various logging code paths to use user IDs. This fixes EMAIL_ADDRESS_VISIBILITY_ADMINS support as well as being more reliable/stable over time. --- zerver/lib/email_mirror.py | 4 ++-- zerver/lib/fix_unreads.py | 2 +- zerver/lib/sessions.py | 2 +- zerver/lib/transfer.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py index d30439e887..d30938b6f6 100644 --- a/zerver/lib/email_mirror.py +++ b/zerver/lib/email_mirror.py @@ -213,8 +213,8 @@ def send_to_missed_message_address(address: str, message: message.Message) -> No else: raise AssertionError("Invalid recipient type!") - logger.info("Successfully processed email from %s to %s" % ( - user_profile.email, recipient_str)) + logger.info("Successfully processed email from user %s to %s" % ( + user_profile.id, recipient_str)) ## Sending the Zulip ## diff --git a/zerver/lib/fix_unreads.py b/zerver/lib/fix_unreads.py index cab0fa24c8..c69b6c68c1 100644 --- a/zerver/lib/fix_unreads.py +++ b/zerver/lib/fix_unreads.py @@ -235,7 +235,7 @@ def fix_pre_pointer(cursor: CursorObj, user_profile: UserProfile) -> None: ) def fix(user_profile: UserProfile) -> None: - logger.info('\n---\nFixing %s:' % (user_profile.email,)) + logger.info('\n---\nFixing %s:' % (user_profile.id,)) with connection.cursor() as cursor: fix_unsubscribed(cursor, user_profile) fix_pre_pointer(cursor, user_profile) diff --git a/zerver/lib/sessions.py b/zerver/lib/sessions.py index 4f74073cbb..a6aaff6ad0 100644 --- a/zerver/lib/sessions.py +++ b/zerver/lib/sessions.py @@ -51,5 +51,5 @@ def delete_all_deactivated_user_sessions() -> None: continue user_profile = get_user_profile_by_id(user_profile_id) if not user_profile.is_active or user_profile.realm.deactivated: - logging.info("Deactivating session for deactivated user %s" % (user_profile.email,)) + logging.info("Deactivating session for deactivated user %s" % (user_profile.id,)) delete_session(session) diff --git a/zerver/lib/transfer.py b/zerver/lib/transfer.py index f7a2ad5d2f..3c67dc34f6 100644 --- a/zerver/lib/transfer.py +++ b/zerver/lib/transfer.py @@ -25,7 +25,7 @@ def transfer_avatars_to_s3(processes: int) -> None: try: with open(file_path, 'rb') as f: s3backend.upload_avatar_image(f, user, user) - logging.info("Uploaded avatar for {} in realm {}".format(user.email, user.realm.name)) + logging.info("Uploaded avatar for {} in realm {}".format(user.id, user.realm.name)) except FileNotFoundError: pass return 0