diff --git a/BaseLib/BaseEntity.py b/BaseLib/BaseEntity.py index 84605e4..718ba12 100644 --- a/BaseLib/BaseEntity.py +++ b/BaseLib/BaseEntity.py @@ -1,4 +1,8 @@ +import logging + + class BaseEntity: + logger = logging.getLogger(__name__) + def get_user(self): raise NotImplementedError - diff --git a/web/views/yandex_auth.py b/web/views/yandex_auth.py index 7bc9e66..ca7b07e 100644 --- a/web/views/yandex_auth.py +++ b/web/views/yandex_auth.py @@ -19,26 +19,26 @@ class YandexAuthView(BaseView): 'code': code }) if response.status_code != 200: - print("Cant access, json: ", response.json()) + self.logger.warning("Cant access, json: %s", response.json()) return '/welcome' access_token = response.json().get('access_token') if access_token is None: - print('no access token') + self.logger.warning('no access token') return '/welcome' info_response = get('https://login.yandex.ru/info', headers={ 'Authorization': f'OAuth {access_token}' }) if info_response.status_code != 200: - print("Cant access, json: ", response.json()) + self.logger.warning("Cant access, json: %s", response.json()) return '/welcome' data = info_response.json() yandex_id = data['id'] if self.request.user.is_authenticated: - print('Got yandex_id', yandex_id, 'writing to db') + self.logger.warning('Got yandex_id %s writing to db', yandex_id) self.request.user.yandex_id = yandex_id self.request.user.save() else: - print('Got yandex_id', yandex_id, 'logging in') + self.logger.warning('Got yandex_id %s logging in', yandex_id) user = CustomUser.objects.filter(yandex_id=yandex_id).first() if user is not None: login(self.request, user)