From e7ccbc914c78949a7bde0c3592fada08ecb015b8 Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Fri, 19 Aug 2016 18:39:43 +0300 Subject: [PATCH] Add production logging support --- archilance/settings/prod.py | 33 +++++++++++++++++++++++++++++++++ archilance/views.py | 12 +++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/archilance/settings/prod.py b/archilance/settings/prod.py index b961979..4acb948 100644 --- a/archilance/settings/prod.py +++ b/archilance/settings/prod.py @@ -17,3 +17,36 @@ DEBUG = True TEMPLATE_DEBUG = True THUMBNAIL_DEBUG = True SECRET_KEY = 'vb6@b9zj7^f!^+x*e8=e!oundyu1!e*&0i(3gu2xwo4%fx4h&n' + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'main_formatter': { + 'format': '%(levelname)s:%(name)s: %(message)s ' + '(%(asctime)s; %(filename)s:%(lineno)d)', + 'datefmt': "%Y-%m-%d %H:%M:%S", + }, + }, + 'handlers': { + 'production_file': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': 'main.log', + 'maxBytes': 1024 * 1024 * 5, # 5 MB + 'backupCount': 7, + 'formatter': 'main_formatter', + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['production_file'], + 'level': 'ERROR', + 'propagate': True, + }, + '': { + 'handlers': ['production_file'], + 'level': "DEBUG", + }, + } +} diff --git a/archilance/views.py b/archilance/views.py index feec3a6..6f4a147 100644 --- a/archilance/views.py +++ b/archilance/views.py @@ -1,14 +1,16 @@ -from django.views.generic import TemplateView, View +from django.core.files.base import ContentFile from django.shortcuts import render from django.template.loader import render_to_string -from django.core.files.base import ContentFile -from work_sell.models import Picture -from projects.models import Order +from django.views.generic import TemplateView, View +import logging + +from chat.models import Documents from common.models import MainPage, PrintDocuments +from projects.models import Order from users.models import ContractorResumeFiles -from chat.models import Documents from work_sell.models import Picture + class HomeTemplateView(View): template_name = 'home.html'