From: Stas Kravets Date: Tue, 20 Sep 2011 13:34:59 +0000 (+0400) Subject: Adding logging to OAuth backends: log the api call errors X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=808eff13093accc2a5e328a8fb473340415af9a2;p=django-social-auth.git Adding logging to OAuth backends: log the api call errors --- diff --git a/social_auth/backends/contrib/mailru.py b/social_auth/backends/contrib/mailru.py index 1879997..3f8e5dd 100644 --- a/social_auth/backends/contrib/mailru.py +++ b/social_auth/backends/contrib/mailru.py @@ -10,6 +10,9 @@ Then update your settings values using registration information """ +import logging +logger = logging.getLogger(__name__) + from django.conf import settings from django.utils import simplejson @@ -87,6 +90,7 @@ def mailru_api(data): try: return simplejson.loads(urlopen(request).read()) except (TypeError, KeyError, IOError, ValueError, IndexError): + logger.error('Could not load data from Mail.ru.', exc_info=True, extra=dict(data=params)) return None diff --git a/social_auth/backends/contrib/odnoklassniki.py b/social_auth/backends/contrib/odnoklassniki.py index ad57701..09a35e6 100644 --- a/social_auth/backends/contrib/odnoklassniki.py +++ b/social_auth/backends/contrib/odnoklassniki.py @@ -11,6 +11,9 @@ mail to set settings values """ +import logging +logger = logging.getLogger(__name__) + from django.conf import settings from django.utils import simplejson @@ -80,6 +83,7 @@ def odnoklassniki_api(data): try: return simplejson.loads(urlopen(request).read()) except (TypeError, KeyError, IOError, ValueError, IndexError): + logger.error('Could not load data from Odnoklassniki.', exc_info=True, extra=dict(data=params)) return None # Backend definition diff --git a/social_auth/backends/contrib/vkontakte.py b/social_auth/backends/contrib/vkontakte.py index b235d4c..670bd7f 100644 --- a/social_auth/backends/contrib/vkontakte.py +++ b/social_auth/backends/contrib/vkontakte.py @@ -5,6 +5,9 @@ This contribution adds support for VKontakte OpenAPI and OAuth 2.0 service in th www.vkontakte.ru. Username is retrieved from the identity returned by server. """ +import logging +logger = logging.getLogger(__name__) + from django.conf import settings from django.contrib.auth import authenticate from django.utils import simplejson @@ -233,6 +236,7 @@ def vkontakte_api(method, data): try: return simplejson.loads(urlopen(api_request).read()) except (TypeError, KeyError, IOError, ValueError, IndexError): + logger.error('Could not load data from VKontakte.', exc_info=True, extra=dict(data=params)) return None