From 8efc260e9bcc9a6dcd1647f517b91d2c957fdce6 Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Wed, 4 Sep 2013 16:41:03 +0400 Subject: [PATCH] Move muranodashboard logs to a separate file. Default file location is /var/log/murano-dashboard.log (hard-coded into horizon config, still have to make it more flexible). In this separate file we have the same log levels which were specified in code (contrary to ubiquitous [error] in apache logs). Fixes: bug MRN-745. Change-Id: Id4977b40cebba7e1fada055443c6c26ab64d9584 --- muranodashboard/panel/services/fields.py | 1 - muranodashboard/settings.py | 12 +++++++++++- setup-centos.sh | 6 ++++++ setup.sh | 6 ++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/muranodashboard/panel/services/fields.py b/muranodashboard/panel/services/fields.py index 6aa4521f0..6a018b44c 100644 --- a/muranodashboard/panel/services/fields.py +++ b/muranodashboard/panel/services/fields.py @@ -75,7 +75,6 @@ class PasswordField(CharField): return name + '-clone' def compare(self, name, form_data): - log.debug('Inside PasswordField compare method') if self.is_original() and self.required: # run compare only for original fields # do not run compare for hidden fields (they are not required) diff --git a/muranodashboard/settings.py b/muranodashboard/settings.py index 9e908735f..fe2d586c8 100644 --- a/muranodashboard/settings.py +++ b/muranodashboard/settings.py @@ -1,7 +1,8 @@ import logging +import traceback import os import sys - +from django.http import HttpResponseServerError from openstack_dashboard import exceptions from muranoclient.common import exceptions as muranoclient @@ -65,6 +66,15 @@ HORIZON_CONFIG = { } +logger = logging.getLogger(__name__) + + +class ExceptionMiddleware(object): + def process_exception(self, request, exception): + logger.error(traceback.format_exc()) + return HttpResponseServerError() + + MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/setup-centos.sh b/setup-centos.sh index 6011652e5..58283adfb 100644 --- a/setup-centos.sh +++ b/setup-centos.sh @@ -118,6 +118,11 @@ HORIZON_CONFIG['exceptions']['not_found'] = EXTENDED_NOT_FOUND_EXCEPTIONS HORIZON_CONFIG['exceptions']['unauthorized'] = EXTENDED_UNAUTHORIZED_EXCEPTIONS HORIZON_CONFIG['customization_module'] = 'muranodashboard.panel.overrides' INSTALLED_APPS += ('muranodashboard','djblets','djblets.datagrid','djblets.util','floppyforms',) +MIDDLEWARE_CLASSES += ('muranodashboard.settings.ExceptionMiddleware',) +LOGGING['formatters'] = {'verbose': {'format': '[%(asctime)s] [%(levelname)s] [pid=%(process)d] %(message)s'}} +LOGGING['handlers']['file'] = {'level': 'DEBUG', 'formatter': 'verbose', 'class': 'logging.FileHandler', 'filename': '/var/log/murano-dashboard.log'} +LOGGING['loggers']['muranodashboard'] = {'handlers': ['file'], 'level': 'DEBUG'} +LOGGING['loggers']['muranoclient'] = {'handlers': ['file'], 'level': 'ERROR'} #if murano-api set up with ssl uncomment next strings #MURANO_API_INSECURE = True #END_MURANO_DASHBOARD @@ -191,6 +196,7 @@ postinst() { rebuildstatic sleep 2 + chown dashboard:dashboard /var/log/murano-dashboard.log service httpd restart } diff --git a/setup.sh b/setup.sh index 8b7ce4cf3..623510451 100644 --- a/setup.sh +++ b/setup.sh @@ -99,6 +99,11 @@ HORIZON_CONFIG['exceptions']['not_found'] = EXTENDED_NOT_FOUND_EXCEPTIONS HORIZON_CONFIG['exceptions']['unauthorized'] = EXTENDED_UNAUTHORIZED_EXCEPTIONS HORIZON_CONFIG['customization_module'] = 'muranodashboard.panel.overrides' INSTALLED_APPS += ('muranodashboard','djblets','djblets.datagrid','djblets.util','floppyforms',) +MIDDLEWARE_CLASSES += ('muranodashboard.settings.ExceptionMiddleware',) +LOGGING['formatters'] = {'verbose': {'format': '[%(asctime)s] [%(levelname)s] [pid=%(process)d] %(message)s'}} +LOGGING['handlers']['file'] = {'level': 'DEBUG', 'formatter': 'verbose', 'class': 'logging.FileHandler', 'filename': '/var/log/murano-dashboard.log'} +LOGGING['loggers']['muranodashboard'] = {'handlers': ['file'], 'level': 'DEBUG'} +LOGGING['loggers']['muranoclient'] = {'handlers': ['file'], 'level': 'ERROR'} #if murano-api set up with ssl uncomment next strings #MURANO_API_INSECURE = True #END_MURANO_DASHBOARD @@ -269,6 +274,7 @@ postinst() { rebuildstatic sleep 2 + chown www-data:www-data /var/log/murano-dashboard.log service apache2 restart } # Command line args'