Configure logging

This commit is contained in:
Gabriel Augendre 2018-05-23 15:36:18 +02:00
parent 499a31fabf
commit b7d7e7098d
2 changed files with 28 additions and 10 deletions

View file

@ -1,16 +1,15 @@
import os
from django.conf import settings
from django.contrib import messages
from django.core.mail import EmailMultiAlternatives
from django.shortcuts import get_object_or_404, redirect
from django.template.loader import render_to_string
from django.urls import reverse
from django.views.generic import CreateView, ListView
from manuels.forms import AddBookForm, AddSuppliesForm
from manuels.models import Teacher, Book, SuppliesRequirement
import logging
logger = logging.getLogger(__name__)
class HomePageView(CreateView):
model = Teacher

View file

@ -17,7 +17,6 @@ import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# 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!
DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev'
ALLOWED_HOSTS = ['web',]
ALLOWED_HOSTS = ['web', ]
if DEBUG:
ALLOWED_HOSTS.extend([
'localhost',
@ -89,7 +88,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'manuels_collection.wsgi.application'
# Database
# 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)
}
# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
@ -116,7 +113,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
@ -130,6 +126,29 @@ USE_L10N = 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)
# https://docs.djangoproject.com/en/2.0/howto/static-files/