Skip to content

Commit

Permalink
Log error messages. Fixes #507
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Apr 4, 2015
1 parent f9caa5a commit 3eae711
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions social/apps/django_app/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.utils.http import urlquote

from social.exceptions import SocialAuthBaseException
from social.utils import social_logger


class SocialAuthExceptionMiddleware(object):
Expand All @@ -31,6 +32,8 @@ def process_exception(self, request, exception):
backend_name = getattr(backend, 'name', 'unknown-backend')

message = self.get_message(request, exception)
social_logger.error(message)

url = self.get_redirect_uri(request, exception)
try:
messages.error(request, message,
Expand Down
3 changes: 3 additions & 0 deletions social/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unicodedata
import collections
import functools
import logging

import six
import requests
Expand All @@ -15,6 +16,8 @@

SETTING_PREFIX = 'SOCIAL_AUTH'

social_logger = logging.Logger('social')

This comment has been minimized.

Copy link
@browniebroke

browniebroke Mar 3, 2016

Contributor

Shouldn't the correct syntax be using the getLogger:

social_logger = logging.getLogger('social')

Using Django, for me it logs No handlers could be found for logger "social"

Whereas it's configured in my settings.py (among other things):

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
            }
        },
    'formatters': {
        'simple': {
            'format': '%(levelname)s %(message)s'
            }
        },
    'handlers': {
        'console': {
            'level': 'INFO',
            'filters': ['require_debug_false'],
            'class': 'logging.StreamHandler',
            'formatter': 'console',
            }
        },
    'loggers': {
        'social': {
            'handlers': ['simple'],
            'level': 'WARNING',
            'propagate': True
        }
    }
}

I have other packages configured that way, and it works.



def import_module(name):
__import__(name)
Expand Down

0 comments on commit 3eae711

Please sign in to comment.