Added error logging on HTTP requests (if config.basic.logging is enabled)
This commit is contained in:
parent
7076a13c53
commit
5e310df926
@ -1,12 +1,14 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
import urllib
|
import urllib
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
import traceback
|
||||||
from bottle import template
|
from bottle import template
|
||||||
|
|
||||||
from aore.config import db_conf
|
from aore.config import db_conf, basic
|
||||||
from aore.dbutils.dbimpl import DBImpl
|
from aore.dbutils.dbimpl import DBImpl
|
||||||
from search import SphinxSearch
|
from search import SphinxSearch
|
||||||
|
|
||||||
@ -54,6 +56,8 @@ class FiasFactory:
|
|||||||
|
|
||||||
results = self.searcher.find(text, strong)
|
results = self.searcher.find(text, strong)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
if basic.logging:
|
||||||
|
logging.error(traceback.format_exc(err))
|
||||||
return dict(error=err.args[0])
|
return dict(error=err.args[0])
|
||||||
|
|
||||||
return results
|
return results
|
||||||
@ -66,6 +70,8 @@ class FiasFactory:
|
|||||||
sql_query = self.normalize_templ.replace("//aoid", aoid_guid)
|
sql_query = self.normalize_templ.replace("//aoid", aoid_guid)
|
||||||
rows = self.db.get_rows(sql_query, True)
|
rows = self.db.get_rows(sql_query, True)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
if basic.logging:
|
||||||
|
logging.error(traceback.format_exc(err))
|
||||||
return dict(error=err.args[0])
|
return dict(error=err.args[0])
|
||||||
|
|
||||||
if len(rows) == 0:
|
if len(rows) == 0:
|
||||||
@ -85,6 +91,8 @@ class FiasFactory:
|
|||||||
sql_query = self.expand_templ.replace("//aoid", normalized_id)
|
sql_query = self.expand_templ.replace("//aoid", normalized_id)
|
||||||
rows = self.db.get_rows(sql_query, True)
|
rows = self.db.get_rows(sql_query, True)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
if basic.logging:
|
||||||
|
logging.error(traceback.format_exc(err))
|
||||||
return dict(error=err.args[0])
|
return dict(error=err.args[0])
|
||||||
|
|
||||||
return rows
|
return rows
|
||||||
|
@ -8,6 +8,7 @@ import sphinxapi
|
|||||||
|
|
||||||
from aore.config import basic
|
from aore.config import basic
|
||||||
from aore.config import sphinx_conf
|
from aore.config import sphinx_conf
|
||||||
|
from aore.miscutils.exceptions import FiasException
|
||||||
from aore.miscutils.trigram import trigram
|
from aore.miscutils.trigram import trigram
|
||||||
from wordentry import WordEntry
|
from wordentry import WordEntry
|
||||||
from wordvariation import VariationType
|
from wordvariation import VariationType
|
||||||
@ -143,6 +144,9 @@ class SphinxSearch:
|
|||||||
if basic.logging:
|
if basic.logging:
|
||||||
logging.info("Sphinx time for {} = {}".format(text, elapsed_t))
|
logging.info("Sphinx time for {} = {}".format(text, elapsed_t))
|
||||||
|
|
||||||
|
if rs is None:
|
||||||
|
raise FiasException("Cannot find sentence.")
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
parsed_ids = []
|
parsed_ids = []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user