From 3622f81c69cde715dd0bfebdc69a4850d451d8e1 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Mon, 30 Jan 2012 12:40:35 -0500 Subject: [PATCH 1/4] update logging to add pid to filename, so we don't have to worry about multiple processes trying to share the same log file --- settings_new_askbot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/settings_new_askbot.py b/settings_new_askbot.py index 9786bd1c91..b66091c405 100644 --- a/settings_new_askbot.py +++ b/settings_new_askbot.py @@ -135,6 +135,9 @@ execfile(os.path.join(BASE_DIR, "settings.py")) # the site admins on every HTTP 500 error. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. + +pid = os.getpid() + LOGGING = { 'version': 1, 'disable_existing_loggers': True, @@ -163,14 +166,14 @@ LOGGING = { 'level' : 'DEBUG' if DEBUG else 'INFO', 'class' : 'logging.handlers.WatchedFileHandler', 'formatter' : 'standard', - 'filename' : LOG_DIR + '/mitx.log', # temporary location for proof of concept + 'filename' : '{0}/mitx.{1}.log'.format(LOG_DIR, pid), 'encoding' : 'utf-8', }, 'app_err' : { 'level' : 'WARNING', 'class' : 'logging.handlers.WatchedFileHandler', 'formatter' : 'standard', - 'filename' : LOG_DIR + '/mitx.err.log', # temporary location for proof of concept + 'filename' : '{0}/mitx.err.{1}.log'.format(LOG_DIR, pid), 'encoding' : 'utf-8', }, # We should actually use this for tracking: @@ -179,7 +182,7 @@ LOGGING = { 'level' : 'INFO', 'class' : 'logging.handlers.WatchedFileHandler', 'formatter' : 'raw', - 'filename' : LOG_DIR + '/tracking.log', + 'filename' : '{0}/tracking.{1}.log'.format(LOG_DIR, pid), 'encoding' : 'utf-8', }, 'mail_admins' : { From 9a0af7f47dde674b2071faa161deb65f3b1a86ec Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Mon, 30 Jan 2012 12:41:59 -0500 Subject: [PATCH 2/4] remove outdated logging comment --- settings_new_askbot.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/settings_new_askbot.py b/settings_new_askbot.py index b66091c405..8ff19cace5 100644 --- a/settings_new_askbot.py +++ b/settings_new_askbot.py @@ -176,8 +176,6 @@ LOGGING = { 'filename' : '{0}/mitx.err.{1}.log'.format(LOG_DIR, pid), 'encoding' : 'utf-8', }, - # We should actually use this for tracking: - # http://pypi.python.org/pypi/ConcurrentLogHandler/0.8.2 'tracking' : { 'level' : 'INFO', 'class' : 'logging.handlers.WatchedFileHandler', From f7eef6b217d52c2aab67c664d906e0b515fecad1 Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Mon, 30 Jan 2012 12:48:47 -0500 Subject: [PATCH 3/4] Removed old settings --- settings_no_askbot.py | 2 -- settings_no_courseware.py | 2 -- 2 files changed, 4 deletions(-) delete mode 100644 settings_no_askbot.py delete mode 100644 settings_no_courseware.py diff --git a/settings_no_askbot.py b/settings_no_askbot.py deleted file mode 100644 index e328f54617..0000000000 --- a/settings_no_askbot.py +++ /dev/null @@ -1,2 +0,0 @@ -ASKBOT_ENABLED = False -execfile("settings_old_askbot.py") diff --git a/settings_no_courseware.py b/settings_no_courseware.py deleted file mode 100644 index 704afa17fc..0000000000 --- a/settings_no_courseware.py +++ /dev/null @@ -1,2 +0,0 @@ -COURSEWARE_ENABLED = False -execfile("settings.py") From b4a91ff486173d661183491da117edb5c2f80289 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Mon, 30 Jan 2012 13:27:18 -0500 Subject: [PATCH 4/4] Suppress op level exception logging middleware if TEMPLATE_DEBUG=True --- util/middleware.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/middleware.py b/util/middleware.py index 3bda2c7873..fe73e67c7b 100644 --- a/util/middleware.py +++ b/util/middleware.py @@ -1,5 +1,6 @@ import logging +from django.conf import settings from django.http import HttpResponse log = logging.getLogger("mitx") @@ -8,6 +9,7 @@ class ExceptionLoggingMiddleware(object): """Just here to log unchecked exceptions that go all the way up the Django stack""" - def process_exception(self, request, exception): - log.exception(exception) - return HttpResponse("Server Error - Please try again later.") + if not settings.TEMPLATE_DEBUG: + def process_exception(self, request, exception): + log.exception(exception) + return HttpResponse("Server Error - Please try again later.")