From 617d4da074535e7c9dfa9d7041cda6474abbf2a8 Mon Sep 17 00:00:00 2001 From: Tony Meyer Date: Tue, 9 Oct 2018 00:42:27 +1300 Subject: [PATCH] Upgrade from Raven to Sentry SDK. --- HISTORY.md | 4 ++++ spoon/__init__.py | 2 +- spoon/daemon.py | 30 +++++++++--------------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 8a6fa45..aae2983 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +### 1.0.7 (2018-10-08) + + - Upgrade from Raven to Sentry SDK. + ### 1.0.6 (2017-03-29) - Add support for debugging. diff --git a/spoon/__init__.py b/spoon/__init__.py index 382021f..9e604c0 100644 --- a/spoon/__init__.py +++ b/spoon/__init__.py @@ -1 +1 @@ -__version__ = "1.0.6" +__version__ = "1.0.7" diff --git a/spoon/daemon.py b/spoon/daemon.py index d8478f9..4ee3c42 100644 --- a/spoon/daemon.py +++ b/spoon/daemon.py @@ -11,13 +11,12 @@ import logging.handlers try: - import raven - import raven.transport - from raven.handlers.logging import SentryHandler + import sentry_sdk + from sentry_sdk.integrations.flask import FlaskIntegration except ImportError: - _has_raven = False + _has_sentry = False else: - _has_raven = True + _has_sentry = True def detach(stdout="/dev/null", stderr=None, stdin="/dev/null", @@ -138,22 +137,11 @@ def _setup_logging(logger, options): stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) - if options["sentry_dsn"] and _has_raven: - client = raven.Client(options["sentry_dsn"], - enable_breadcrumbs=False, - transport=raven.transport.HTTPTransport) - - # Add Sentry handle to application logger. - sentry_handler = SentryHandler(client) - sentry_handler.setLevel(logging.WARNING) - logger.addHandler(sentry_handler) - - null_loggers = [ - logging.getLogger("sentry.errors"), - logging.getLogger("sentry.errors.uncaught") - ] - for null_logger in null_loggers: - null_logger.handlers = [logging.NullHandler()] + if options["sentry_dsn"] and _has_sentry: + sentry_sdk.init( + dsn=options["sentry_dsn"], + integrations=[FlaskIntegration()] + ) if options["debug"]: stream_handler.setLevel(logging.DEBUG)