Merge "Fix problems with customized HorizonMiddleware on development server."

This commit is contained in:
Jenkins 2013-10-04 16:02:19 +00:00 committed by Gerrit Code Review
commit 30eab572ee
4 changed files with 28 additions and 15 deletions

View File

@ -0,0 +1,26 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from horizon.middleware import HorizonMiddleware
import traceback
import logging
logger = logging.getLogger(__name__)
class ExceptionMiddleware(HorizonMiddleware):
def process_exception(self, request, exception):
logger.error(traceback.format_exc())
return super(ExceptionMiddleware, self).process_exception(
request, exception)

View File

@ -1,11 +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
from horizon.middleware import HorizonMiddleware
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
BIN_DIR = os.path.abspath(os.path.join(ROOT_PATH, '..', 'bin'))
@ -67,16 +64,6 @@ HORIZON_CONFIG = {
}
logger = logging.getLogger(__name__)
class ExceptionMiddleware(HorizonMiddleware):
def process_exception(self, request, exception):
logger.error(traceback.format_exc())
return super(ExceptionMiddleware, self).process_exception(
request, exception)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',

View File

@ -117,7 +117,7 @@ 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','floppyforms',)
MIDDLEWARE_CLASSES += ('muranodashboard.settings.ExceptionMiddleware',)
MIDDLEWARE_CLASSES += ('muranodashboard.middleware.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'}

View File

@ -98,7 +98,7 @@ 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','floppyforms',)
MIDDLEWARE_CLASSES += ('muranodashboard.settings.ExceptionMiddleware',)
MIDDLEWARE_CLASSES += ('muranodashboard.middleware.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'}