Browse Source

Merge pull request #99 from grap/7.0-improve-sentry-setting

[ADD] [7.0] 'sentry_logger' Possibility to customize logging level
pull/106/head
Guewen Baconnier 10 years ago
parent
commit
967cc3dfd1
  1. 8
      sentry_logger/__init__.py
  2. 12
      sentry_logger/__openerp__.py

8
sentry_logger/__init__.py

@ -26,6 +26,8 @@ import cgitb
from openerp.tools import config
from openerp.addons.web.controllers.main import Session
_DEFAULT_LOGGING_LEVEL = logging.ERROR
try:
from .odoo_sentry_client import OdooClient
from .odoo_sentry_handler import OdooSentryHandler
@ -40,12 +42,16 @@ try:
cgitb.enable()
# Get DSN info from config file or ~/.openerp_serverrc (recommended)
dsn = config.get('sentry_dsn')
try:
level = getattr(logging, config.get('sentry_logging_level'))
except (AttributeError, TypeError):
level = _DEFAULT_LOGGING_LEVEL
# Create Client
client = OdooClient(
dsn=dsn,
processors=processors,
)
handler = OdooSentryHandler(client, level=logging.ERROR)
handler = OdooSentryHandler(client, level=level)
root_logger.addHandler(handler)
else:
root_logger.warn(u"Sentry DSN not defined in config file")

12
sentry_logger/__openerp__.py

@ -27,12 +27,18 @@
'description': """
Sentry
======
Integration with Sentry Error reporting engine.
Insert sentry DSN to ~/.openerp_serverrc with value:
Settings:
---------
You have to add extra parameters in your odoo config file (~/.openerp_serverrc)
* mandatory parameters:
* Insert sentry DSN with value:
sentry_dsn = sync+<Your Sentry DSN>
* optional parameters:
* Define the level of log sent to sentry:
sentry_logging_level = WARNING
(by default ERROR)
Optional Dependencies
---------------------

Loading…
Cancel
Save