elasticsearch log fix

This commit is contained in:
James Turk 2012-07-11 14:58:00 -04:00
parent ebba8174ee
commit dd5e94cf86

View File

@ -7,11 +7,11 @@ from ..conf import settings
from pyes import ES
es = ES(settings.ELASTICSEARCH_HOST)
log = logging.getLogger('oyster.ext.elasticsearch')
class ElasticSearchPush(Task):
# results go straight to elasticsearch
ignore_result = True
log = logging.getLogger('oyster.ext.elasticsearch')
def run(self, doc_id):
doc = kernel.db.tracked.find_one({'_id': doc_id})
@ -19,19 +19,18 @@ class ElasticSearchPush(Task):
try:
text = kernel.extract_text(doc)
if not text:
self.log.info('no text for %s', doc_id,
extra={'doc_class':doc['doc_class']})
log.info('no text for %s', doc_id,
extra={'doc_class':doc['doc_class']})
return
self.log.info('tracked %s', doc_id,
extra={'doc_class':doc['doc_class']})
log.info('tracked %s', doc_id,
extra={'doc_class':doc['doc_class']})
es.index(dict(doc['metadata'], text=text),
settings.ELASTICSEARCH_INDEX,
settings.ELASTICSEARCH_DOC_TYPE,
id=doc_id)
except Exception as e:
self.log.warning('error tracking %s', doc_id,
extra={'doc_class':doc['doc_class']},
exc_info=True)
log.warning('error tracking %s', doc_id,
extra={'doc_class':doc['doc_class']}, exc_info=True)
raise