Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Jul 11, 2024
1 parent 2326660 commit 243b051
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/apps/users/adapters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations

import logging
import traceback
from typing import Self

from allauth.account.adapter import DefaultAccountAdapter
Expand All @@ -8,6 +8,16 @@
from django.http import HttpRequest


def report(e):
logging.error(str(e))
try:
from sentry_sdk import capture_exception

capture_exception(e)
except Exception:
logging.error(traceback.format_exc())


class AccountAdapter(DefaultAccountAdapter):
def is_open_for_signup(self: Self, request: HttpRequest) -> bool:
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
Expand All @@ -18,5 +28,14 @@ class SocialAccountAdapter(DefaultSocialAccountAdapter):
just for debugging obscure integration exceptions
"""

def authentication_error(self, *args, **kwargs):
print(args, kwargs)
def on_authentication_error(
self: Self, request, provider, error=None, exception=None, extra_context=None
):
report(exception)
return super().on_authentication_error(
request,
provider,
error=error,
exception=exception,
extra_context=extra_context,
)

0 comments on commit 243b051

Please sign in to comment.