use logging correctly
This commit is contained in:
parent
b4b55a811d
commit
8ee3f561a4
|
@ -1,3 +1,5 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.core.mail import EmailMultiAlternatives
|
from django.core.mail import EmailMultiAlternatives
|
||||||
|
@ -7,6 +9,9 @@ from django.utils.encoding import force_bytes
|
||||||
from django.utils.http import urlsafe_base64_encode
|
from django.utils.http import urlsafe_base64_encode
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class NotifyActivateUserByEmail:
|
class NotifyActivateUserByEmail:
|
||||||
def get_email_context(self, user):
|
def get_email_context(self, user):
|
||||||
"""
|
"""
|
||||||
|
@ -49,10 +54,11 @@ class NotifyActivateUserByEmail:
|
||||||
email_message.attach_alternative(html_email, 'text/html')
|
email_message.attach_alternative(html_email, 'text/html')
|
||||||
try:
|
try:
|
||||||
if settings.DEVELOPMENT:
|
if settings.DEVELOPMENT:
|
||||||
print(to_email)
|
logger.warning(to_email)
|
||||||
print(body)
|
logger.warning(body)
|
||||||
return
|
return
|
||||||
|
|
||||||
email_message.send()
|
email_message.send()
|
||||||
except Exception:
|
except Exception as err:
|
||||||
|
logger.error(err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -207,3 +207,18 @@ SUPPORTED_CREDENTIALS = config(
|
||||||
default='[]',
|
default='[]',
|
||||||
cast=literal_eval
|
cast=literal_eval
|
||||||
)
|
)
|
||||||
|
|
||||||
|
LOGGING = {
|
||||||
|
"version": 1,
|
||||||
|
"disable_existing_loggers": False,
|
||||||
|
"handlers": {
|
||||||
|
"console": {"class": "logging.StreamHandler"},
|
||||||
|
},
|
||||||
|
"loggers": {
|
||||||
|
"django": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": "INFO",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue