Skip to content

Commit

Permalink
Adding logging to views that execute descriptors.
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenDavie committed Aug 27, 2012
1 parent aeb9efd commit 15dde11
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sharrock/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from django.shortcuts import render_to_response
from django.http import Http404, HttpResponse
from django.conf import settings
import traceback
import logging

log = logging.getLogger('sharrock')

def check_extension(extension):
if not extension in ['html','xml','json']:
Expand Down Expand Up @@ -76,6 +78,9 @@ def execute_service(request,app,version,service_name,extension='json'):
return HttpResponse(str(pr),status=400) # missing parameter
except Conflict as con:
return HttpResponse(str(con),status=409) # something user-resolvable is wrong with the function
except Exception as e:
log.exception('Exception while accessing function %s.' % service_name)
raise e

def execute_resource(request,app,version,resource_name,extension='json',model_id=None):
"""
Expand All @@ -102,7 +107,7 @@ def execute_resource(request,app,version,resource_name,extension='json',model_id
except Conflict as con:
return HttpResponse(str(con),status=409) # something user-resolvable is wrong with the resource
except Exception as e:
traceback.print_exc()
log.exception('Exception while accessing resource %s.' % resource_name)
raise e

def resource_directory(request,app=None,version=None,extension='html'):
Expand Down

0 comments on commit 15dde11

Please sign in to comment.