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
This commit is contained in:
Timur Sufiev 2013-09-04 16:41:03 +04:00
parent d4a9eb9740
commit 8efc260e9b
4 changed files with 23 additions and 2 deletions

View File

@ -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)

View File

@ -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',

View File

@ -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
}

View File

@ -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'