Configure logging
This commit is contained in:
parent
499a31fabf
commit
b7d7e7098d
2 changed files with 28 additions and 10 deletions
|
@ -1,16 +1,15 @@
|
||||||
import os
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.mail import EmailMultiAlternatives
|
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.template.loader import render_to_string
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.views.generic import CreateView, ListView
|
from django.views.generic import CreateView, ListView
|
||||||
|
|
||||||
from manuels.forms import AddBookForm, AddSuppliesForm
|
from manuels.forms import AddBookForm, AddSuppliesForm
|
||||||
from manuels.models import Teacher, Book, SuppliesRequirement
|
from manuels.models import Teacher, Book, SuppliesRequirement
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class HomePageView(CreateView):
|
class HomePageView(CreateView):
|
||||||
model = Teacher
|
model = Teacher
|
||||||
|
|
|
@ -17,7 +17,6 @@ import dj_database_url
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ SECRET_KEY = os.getenv('SECRET_KEY', 'f6j7c0j%-^$r6&hf4!=db1=)88&ve3qwbsgl3ykd22
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev'
|
DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev'
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['web',]
|
ALLOWED_HOSTS = ['web', ]
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
ALLOWED_HOSTS.extend([
|
ALLOWED_HOSTS.extend([
|
||||||
'localhost',
|
'localhost',
|
||||||
|
@ -89,7 +88,6 @@ TEMPLATES = [
|
||||||
|
|
||||||
WSGI_APPLICATION = 'manuels_collection.wsgi.application'
|
WSGI_APPLICATION = 'manuels_collection.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
||||||
|
|
||||||
|
@ -97,7 +95,6 @@ DATABASES = {
|
||||||
'default': dj_database_url.config(default='sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3'), conn_max_age=600)
|
'default': dj_database_url.config(default='sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3'), conn_max_age=600)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
@ -116,7 +113,6 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/2.0/topics/i18n/
|
# https://docs.djangoproject.com/en/2.0/topics/i18n/
|
||||||
|
|
||||||
|
@ -130,6 +126,29 @@ USE_L10N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
LOG_LEVEL = 'DEBUG' if DEBUG else 'INFO'
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'formatters': {
|
||||||
|
'verbose': {
|
||||||
|
'format': '[%(asctime)s] [%(process)d] [%(levelname)s] %(module)s - %(message)s'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'handlers': {
|
||||||
|
'console': {
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
'formatter': 'verbose'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'manuels': {
|
||||||
|
'handlers': ['console'],
|
||||||
|
'level': LOG_LEVEL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/2.0/howto/static-files/
|
# https://docs.djangoproject.com/en/2.0/howto/static-files/
|
||||||
|
|
Loading…
Reference in a new issue