Skip to content

Commit 176d028

Browse files
committed
updating loggers
1 parent 9117331 commit 176d028

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

conduit/api/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _get_resource_uri(self, obj=None, data=None):
9595

9696
try:
9797
if obj:
98-
resource_uri = reverse(detail_view_name, kwargs={self.Meta.pk_field: getattr( obj, self.Meta.pk_field )})
98+
resource_uri = reverse(detail_view_name, kwargs={self.Meta.pk_field: getattr(obj, self.Meta.pk_field)})
9999
else:
100100
resource_uri = reverse(list_view_name)
101101
except NoReverseMatch:

conduit/api/fields.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import six
2+
import pprint
23
from importlib import import_module
34
from django.core.urlresolvers import resolve
45
from django.db.models.loading import get_model
56

7+
import logging
8+
logger = logging.getLogger('conduit')
9+
610

711
def import_class(resource_cls_str):
812
# import resource class dynamically
@@ -127,6 +131,8 @@ def dehydrate(self, request, parent_inst, bundle=None):
127131
if self.embed:
128132
for methodname in self.dehydrate_conduit:
129133
bound_method = resource._get_method(methodname)
134+
pretty_kwargs = pprint.pformat(kwargs)
135+
logger.debug('\n[ {0}.{1} ]: kwargs = \n{2}'.format(resource.__class__.__name__, bound_method.__name__, pretty_kwargs))
130136
(request, args, kwargs,) = bound_method(request, *args, **kwargs)
131137
# Grab the dehydrated data and place it on the parent's bundle
132138
related_bundle = kwargs['bundles'][0]
@@ -153,6 +159,8 @@ def save_related(self, request, parent_inst, obj, rel_obj_data):
153159
resource.Meta.api = parent_inst.Meta.api
154160
for methodname in self.save_conduit:
155161
bound_method = resource._get_method(methodname)
162+
pretty_kwargs = pprint.pformat(kwargs)
163+
logger.debug('\n[ {0}.{1} ]: kwargs = \n{2}'.format(resource.__class__.__name__, bound_method.__name__, pretty_kwargs))
156164
(request, args, kwargs,) = bound_method(request, *args, **kwargs)
157165

158166
related_obj = kwargs['bundles'][0]['obj']
@@ -222,6 +230,8 @@ def dehydrate(self, request, parent_inst, bundle=None):
222230
if self.embed:
223231
for methodname in self.dehydrate_conduit:
224232
bound_method = resource._get_method(methodname)
233+
pretty_kwargs = pprint.pformat(kwargs)
234+
logger.debug('\n[ {0}.{1} ]: kwargs = \n{2}'.format(resource.__class__.__name__, bound_method.__name__, pretty_kwargs))
225235
(request, args, kwargs,) = bound_method(request, *args, **kwargs)
226236

227237
dehydrated_data = []
@@ -379,7 +389,7 @@ def fetch_resource(self, model, api=None):
379389
attribute based on a model. First looks for `app_name.Model_name`,
380390
falling back to `Model_name`.
381391
382-
If no resource_map is specified it will fall back to the API
392+
If no resource_map is specified it will fall back to the API
383393
"""
384394
app_label = model._meta.app_label
385395
model_name = model.__name__
@@ -411,6 +421,8 @@ def dehydrate(self, request, parent_inst, bundle=None):
411421
kwargs = {'objs': [obj], 'pub': ['detail', 'get']}
412422
for methodname in self.dehydrate_conduit:
413423
bound_method = resource._get_method(methodname)
424+
pretty_kwargs = pprint.pformat(kwargs)
425+
logger.debug('\n[ {0}.{1} ]: kwargs = \n{2}'.format(resource.__class__.__name__, bound_method.__name__, pretty_kwargs))
414426
(request, args, kwargs,) = bound_method(request, *args, **kwargs)
415427
# Grab the dehydrated data and place it on the parent's bundle
416428
related_bundle = kwargs['bundles'][0]

conduit/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pprint
12
from importlib import import_module
23
from conduit.exceptions import HttpInterrupt
34
from django.db import transaction
@@ -35,7 +36,8 @@ def view(self, request, *args, **kwargs):
3536
with transaction.commit_on_success():
3637
for method_string in self.Meta.conduit[:-1]:
3738
bound_method = self._get_method(method_string)
38-
logger.debug( "\n[ {0} ]: kwargs = \n{1}".format( bound_method.__name__, kwargs ) )
39+
pretty_kwargs = pprint.pformat(kwargs)
40+
logger.debug('\n[ {0}.{1} ]: kwargs = \n{2}'.format(self.__class__.__name__, bound_method.__name__, pretty_kwargs))
3941
(request, args, kwargs,) = bound_method( request, *args, **kwargs)
4042
except HttpInterrupt as e:
4143
return e.response
@@ -51,4 +53,3 @@ def run(self, *args, **kwargs):
5153
bound_method = self._get_method(method_string)
5254
(args, kwargs,) = bound_method(*args, **kwargs)
5355
return args, kwargs
54-

conduit/test/test_resources.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,10 @@ def test_gfk_empty_data(self):
339339
content_type='application/json'
340340
)
341341
content = json.loads(response.content.decode())
342+
print(content)
342343

343344
self.assertTrue(content['id'])
344345
self.assertTrue(content['resource_uri'])
345346
self.assertEqual(content['content_type'], None)
346347
self.assertEqual(content['content_type_id'], None)
347-
self.assertEqual(content['object_id'], None)
348+
self.assertEqual(content['object_id'], None)

example/example/settings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,14 @@
179179
'propagate': True,
180180
},
181181
'django.db': {
182-
'handlers': ['null'],
182+
'handlers': ['null'],
183183
'level':'ERROR',
184184
'propagate': False,
185185
},
186+
'conduit': {
187+
'handlers': ['console'],
188+
'level': 'DEBUG',
189+
'propogate': True,
190+
},
186191
}
187192
}

0 commit comments

Comments
 (0)