Permalink
Browse files

added a logger

  • Loading branch information...
1 parent 5aba519 commit 3f12b954903efbb83fb3456f7741f31623a99fdb @tarekziade tarekziade committed Mar 5, 2013
Showing with 9 additions and 1 deletion.
  1. +4 −0 monolith/web/__init__.py
  2. +5 −1 monolith/web/views.py
@@ -1,6 +1,7 @@
"""Main entry point
"""
import datetime
+import logging
from pyramid.config import Configurator
from pyramid.events import NewRequest
@@ -9,6 +10,9 @@
from pyelasticsearch import ElasticSearch
+logger = logging.getLogger('monolith.web')
+
+
def attach_elasticsearch(event):
request = event.request
event.request.es = request.registry.es
@@ -5,6 +5,8 @@
from pyelasticsearch.exceptions import ElasticHttpError
+from monolith.web import logger
+
class ElasticSearchQuery(MappingSchema):
start = SchemaNode(Date(), location='body', type='datetime.datetime')
@@ -42,8 +44,10 @@ def valid_json_body(request):
@es_time.post(validators=(valid_json_body,), renderer='json')
def query_es_time(request):
+ query = request.validated['body']
+ logger.info(query)
try:
- return request.es.search(request.validated['body'], index='time_*')
+ return request.es.search(query, index='time_*')
except ElasticHttpError as e:
request.errors.status = e.status_code
request.errors.add('body', description=e.error)

0 comments on commit 3f12b95

Please sign in to comment.