Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added a logger

  • Loading branch information...
commit 3f12b954903efbb83fb3456f7741f31623a99fdb 1 parent 5aba519
Tarek Ziade authored March 05, 2013
4  monolith/web/__init__.py
... ...
@@ -1,6 +1,7 @@
1 1
 """Main entry point
2 2
 """
3 3
 import datetime
  4
+import logging
4 5
 
5 6
 from pyramid.config import Configurator
6 7
 from pyramid.events import NewRequest
@@ -9,6 +10,9 @@
9 10
 from pyelasticsearch import ElasticSearch
10 11
 
11 12
 
  13
+logger = logging.getLogger('monolith.web')
  14
+
  15
+
12 16
 def attach_elasticsearch(event):
13 17
     request = event.request
14 18
     event.request.es = request.registry.es
6  monolith/web/views.py
@@ -5,6 +5,8 @@
5 5
 
6 6
 from pyelasticsearch.exceptions import ElasticHttpError
7 7
 
  8
+from monolith.web import logger
  9
+
8 10
 
9 11
 class ElasticSearchQuery(MappingSchema):
10 12
     start = SchemaNode(Date(), location='body', type='datetime.datetime')
@@ -42,8 +44,10 @@ def valid_json_body(request):
42 44
 
43 45
 @es_time.post(validators=(valid_json_body,), renderer='json')
44 46
 def query_es_time(request):
  47
+    query = request.validated['body']
  48
+    logger.info(query)
45 49
     try:
46  
-        return request.es.search(request.validated['body'], index='time_*')
  50
+        return request.es.search(query, index='time_*')
47 51
     except ElasticHttpError as e:
48 52
         request.errors.status = e.status_code
49 53
         request.errors.add('body', description=e.error)

0 notes on commit 3f12b95

Please sign in to comment.
Something went wrong with that request. Please try again.