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.template import loader
|
||||
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
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NotifyActivateUserByEmail:
|
||||
def get_email_context(self, user):
|
||||
"""
|
||||
|
@ -49,10 +54,11 @@ class NotifyActivateUserByEmail:
|
|||
email_message.attach_alternative(html_email, 'text/html')
|
||||
try:
|
||||
if settings.DEVELOPMENT:
|
||||
print(to_email)
|
||||
print(body)
|
||||
logger.warning(to_email)
|
||||
logger.warning(body)
|
||||
return
|
||||
|
||||
email_message.send()
|
||||
except Exception:
|
||||
except Exception as err:
|
||||
logger.error(err)
|
||||
return
|
||||
|
|
|
@ -207,3 +207,18 @@ SUPPORTED_CREDENTIALS = config(
|
|||
default='[]',
|
||||
cast=literal_eval
|
||||
)
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"handlers": {
|
||||
"console": {"class": "logging.StreamHandler"},
|
||||
},
|
||||
"loggers": {
|
||||
"django": {
|
||||
"handlers": ["console"],
|
||||
"level": "INFO",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue