Skip to content

Commit

Permalink
Added and improved logs for production env
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben69695 committed Dec 21, 2022
1 parent 076ce22 commit 815a31f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
- DEBUG=True
- PGSSL=False
- SECRET_KEY=${DJANGO_SECRET_KEY}
- DJANGO_LOG_LEVEL=${DJANGO_LOG_LEVEL}
- EMAIL_HOST=${EMAIL_HOST}
- EMAIL_PORT=${EMAIL_PORT}
- EMAIL_HOST_USER=${EMAIL_HOST_USER}
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ psycopg2-binary==2.9.3
dj-database-url==0.5.0
gunicorn==20.1.0
whitenoise==6.2.0
requests==2.28.0
requests==2.28.0
44 changes: 43 additions & 1 deletion webpersonal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,48 @@

CSRF_TRUSTED_ORIGINS = [] if DEBUG else ['https://rarrebola-personalweb-ny2i4.ondigitalocean.app', 'https://www.rubenarrebola.pro']

# Logging part
LOG_LEVEL = os.getenv('DJANGO_LOG_LEVEL', 'INFO')

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '[{levelname}] {module} {process:d} {thread:d} :: {message}',
'style': '{',
},
'simple': {
'format': '[{levelname}] :: {message}',
'style': '{',
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': LOG_LEVEL,
},
'core': {
'handlers': ['console'],
'level': LOG_LEVEL,
},
'portfolio': {
'handlers': ['console'],
'level': LOG_LEVEL,
},
'experience': {
'handlers': ['console'],
'level': LOG_LEVEL,
}
},
}


# Application definition

Expand Down Expand Up @@ -136,7 +178,7 @@
# Email backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' if DEBUG else 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.environ.get('EMAIL_HOST', None)
EMAIL_PORT = int(os.environ.get('EMAIL_PORT', '0'))
EMAIL_PORT = int(os.environ.get('EMAIL_PORT', 0))
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', None)
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', None)
EMAIL_USE_TLS = False if os.environ.get('EMAIL_USE_TLS', 'False') == 'False' else True
Expand Down

0 comments on commit 815a31f

Please sign in to comment.