# -*- coding: utf-8 -*- ############################################################################### # # OpenERP, Open Source Management Solution # This module copyright (C) 2010 - 2014 Savoir-faire Linux # (). # # 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 import cgitb from openerp.tools import config from openerp.addons.web.controllers.main import Session from .odoo_sentry_client import OdooClient from .odoo_sentry_handler import OdooSentryHandler root_logger = logging.root processors = ( 'raven.processors.SanitizePasswordsProcessor', 'raven_sanitize_openerp.OpenerpPasswordsProcessor' ) if config.get(u'sentry_dsn'): cgitb.enable() # Get DSN info from config file or ~/.openerp_serverrc (recommended) dsn = config.get('sentry_dsn') # Create Client client = OdooClient( dsn=dsn, processors=processors, ) handler = OdooSentryHandler(client, level=logging.ERROR) root_logger.addHandler(handler) else: root_logger.warn(u"Sentry DSN not defined in config file") client = None # Inject sentry_activated to session to display error message or not old_session_info = Session.session_info def session_info(self, req): res = old_session_info(self, req) res['sentry_activated'] = bool(client) return res Session.session_info = session_info