[IMP] core: log bad queries as ERROR

Also adapt default config and config mapping.
This commit is contained in:
Christophe Simonis
2017-07-26 17:46:20 +02:00
parent e8d4a11e6e
commit c4e9b854ff
3 changed files with 7 additions and 7 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
from psycopg2 import IntegrityError from psycopg2 import IntegrityError
from odoo.addons.mail.tests.common import TestMail from odoo.addons.mail.tests.common import TestMail
from odoo.tools.misc import mute_logger
class TestMailFollowers(TestMail): class TestMailFollowers(TestMail):
@@ -134,7 +135,7 @@ class TestMailFollowers(TestMail):
test_channel = self.env['mail.channel'].create({ test_channel = self.env['mail.channel'].create({
'name': 'I used to be schizo, but now we are alright.' 'name': 'I used to be schizo, but now we are alright.'
}) })
with self.assertRaises(IntegrityError): with self.assertRaises(IntegrityError), mute_logger('odoo.sql_db'):
self.env['mail.followers'].create({ self.env['mail.followers'].create({
'res_model_id': self.env['ir.model']._get('mail.channel').id, 'res_model_id': self.env['ir.model']._get('mail.channel').id,
'res_id': test_channel.id, 'res_id': test_channel.id,
+4 -5
View File
@@ -188,17 +188,16 @@ def init_logger():
for logconfig_item in logging_configurations: for logconfig_item in logging_configurations:
_logger.debug('logger level set: "%s"', logconfig_item) _logger.debug('logger level set: "%s"', logconfig_item)
DEFAULT_LOG_CONFIGURATION = [ DEFAULT_LOG_CONFIGURATION = [
'odoo.http.rpc.request:INFO', 'odoo.http.rpc.request:INFO',
'odoo.http.rpc.response:INFO', 'odoo.http.rpc.response:INFO',
'odoo.addons.web.http:INFO',
'odoo.sql_db:INFO',
':INFO', ':INFO',
] ]
PSEUDOCONFIG_MAPPER = { PSEUDOCONFIG_MAPPER = {
'debug_rpc_answer': ['odoo:DEBUG','odoo.http.rpc.request:DEBUG', 'odoo.http.rpc.response:DEBUG'], 'debug_rpc_answer': ['odoo:DEBUG', 'odoo.sql_db:INFO', 'odoo.http.rpc:DEBUG'],
'debug_rpc': ['odoo:DEBUG','odoo.http.rpc.request:DEBUG'], 'debug_rpc': ['odoo:DEBUG', 'odoo.sql_db:INFO', 'odoo.http.rpc.request:DEBUG'],
'debug': ['odoo:DEBUG'], 'debug': ['odoo:DEBUG', 'odoo.sql_db:INFO'],
'debug_sql': ['odoo.sql_db:DEBUG'], 'debug_sql': ['odoo.sql_db:DEBUG'],
'info': [], 'info': [],
'warn': ['odoo:WARNING', 'werkzeug:WARNING'], 'warn': ['odoo:WARNING', 'werkzeug:WARNING'],
+1 -1
View File
@@ -231,7 +231,7 @@ class Cursor(object):
res = self._obj.execute(query, params) res = self._obj.execute(query, params)
except Exception as e: except Exception as e:
if self._default_log_exceptions if log_exceptions is None else log_exceptions: if self._default_log_exceptions if log_exceptions is None else log_exceptions:
_logger.info("bad query: %s \nERROR: %s", self._obj.query or query, e) _logger.error("bad query: %s\nERROR: %s", self._obj.query or query, e)
raise raise
# simple query count is always computed # simple query count is always computed