From 3f779a5cae7bd4ca0399cf06e331f5047ec0e343 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Fri, 28 Feb 2014 17:10:55 +0100 Subject: [PATCH] [IMP] Add the ir_logging object where we will store the log messages (exception, error and warning) bzr revid: stw@openerp.com-20140228161055-98897xl1r46mf9mr --- openerp/addons/base/ir/__init__.py | 1 + openerp/addons/base/ir/ir_logging.py | 52 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 openerp/addons/base/ir/ir_logging.py diff --git a/openerp/addons/base/ir/__init__.py b/openerp/addons/base/ir/__init__.py index b3df5bcbccb..9aa1e7c42a2 100644 --- a/openerp/addons/base/ir/__init__.py +++ b/openerp/addons/base/ir/__init__.py @@ -39,6 +39,7 @@ import ir_mail_server import ir_fields import ir_qweb import ir_http +import ir_logging # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/addons/base/ir/ir_logging.py b/openerp/addons/base/ir/ir_logging.py new file mode 100644 index 00000000000..66708aa729a --- /dev/null +++ b/openerp/addons/base/ir/ir_logging.py @@ -0,0 +1,52 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014 OpenERP SA () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import logging + +from openerp.osv import osv, fields +from openerp.tools.translate import _ + +class ir_logging(osv.Model): + _name = 'ir.logging' + + EXCEPTIONS_TYPE = [ + ('client', 'Client'), + ('server', 'Server') + ] + + _columns = { + 'name': fields.char('Name', required=True), + 'type': fields.selection(EXCEPTIONS_TYPE, string='Type', required=True, select=True), + 'dbname': fields.char('Database Name'), + 'level': fields.char('Level'), + 'message': fields.text('Message', required=True), + 'exception': fields.text('Exception'), + 'path': fields.char('Path', required=True), + 'func': fields.char('Function', required=True), + 'line': fields.char('Line', required=True), + } + + def call_function(self, cr, uid, ids, context=None): + logger = logging.getLogger() + logger.error("I think there is an error") + try: + raise Exception("I want to kill your process...") + except Exception, ex: + logger.exception("Please log me into the database") + return True \ No newline at end of file