diff --git a/zerver/forms.py b/zerver/forms.py index 12691fc5ac..adae81ce60 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -413,6 +413,8 @@ class CreateUserForm(forms.Form): class OurAuthenticationForm(AuthenticationForm): + logger = logging.getLogger("zulip.auth.OurAuthenticationForm") + def clean(self) -> Dict[str, Any]: username = self.cleaned_data.get("username") password = self.cleaned_data.get("password") @@ -459,7 +461,7 @@ class OurAuthenticationForm(AuthenticationForm): raise ValidationError(error_message) if return_data.get("invalid_subdomain"): - logging.warning( + self.logger.info( "User attempted password login to wrong subdomain %s. Matching accounts: %s", subdomain, return_data.get("matching_user_ids_in_different_realms"), diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 14b47a45b4..a26d1dbb26 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -823,13 +823,13 @@ class LoginTest(ZulipTestCase): def test_login_wrong_subdomain(self) -> None: user_profile = self.mit_user("sipbtest") email = user_profile.delivery_email - with self.assertLogs(level="WARNING") as m: + with self.assertLogs("zulip.auth.OurAuthenticationForm", level="INFO") as m: result = self.login_with_return(email, "xxx") matching_accounts_dict = {"realm_id": user_profile.realm_id, "id": user_profile.id} self.assertEqual( m.output, [ - f"WARNING:root:User attempted password login to wrong subdomain zulip. Matching accounts: [{matching_accounts_dict}]" + f"INFO:zulip.auth.OurAuthenticationForm:User attempted password login to wrong subdomain zulip. Matching accounts: [{matching_accounts_dict}]" ], ) self.assertEqual(result.status_code, 200)