diff --git a/elasticapm/contrib/flask/__init__.py b/elasticapm/contrib/flask/__init__.py index fdb6906dd..b6e4e312b 100644 --- a/elasticapm/contrib/flask/__init__.py +++ b/elasticapm/contrib/flask/__init__.py @@ -31,9 +31,6 @@ from __future__ import absolute_import -import logging -import warnings - import flask from flask import request, signals @@ -41,9 +38,8 @@ import elasticapm.instrumentation.control from elasticapm import get_client from elasticapm.base import Client -from elasticapm.conf import constants, setup_logging +from elasticapm.conf import constants from elasticapm.contrib.flask.utils import get_data_from_request, get_data_from_response -from elasticapm.handlers.logging import LoggingHandler from elasticapm.traces import execution_context from elasticapm.utils import build_name_with_http_method_prefix from elasticapm.utils.disttracing import TraceParent @@ -81,14 +77,8 @@ class ElasticAPM(object): >>> elasticapm.capture_message('hello, world!') """ - def __init__(self, app=None, client=None, client_cls=Client, logging=False, **defaults) -> None: + def __init__(self, app=None, client=None, client_cls=Client, **defaults) -> None: self.app = app - self.logging = logging - if self.logging: - warnings.warn( - "Flask log shipping is deprecated. See the Flask docs for more info and alternatives.", - DeprecationWarning, - ) self.client = client or get_client() self.client_cls = client_cls @@ -127,14 +117,6 @@ def init_app(self, app, **defaults) -> None: self.client = self.client_cls(config, **defaults) - # 0 is a valid log level (NOTSET), so we need to check explicitly for it - if self.logging or self.logging is logging.NOTSET: - if self.logging is not True: - kwargs = {"level": self.logging} - else: - kwargs = {} - setup_logging(LoggingHandler(self.client, **kwargs)) - signals.got_request_exception.connect(self.handle_exception, sender=app, weak=False) try: diff --git a/tests/contrib/flask/flask_tests.py b/tests/contrib/flask/flask_tests.py index 7ffce68cf..4a38dc3b4 100644 --- a/tests/contrib/flask/flask_tests.py +++ b/tests/contrib/flask/flask_tests.py @@ -441,32 +441,6 @@ def test_rum_tracing_context_processor(flask_apm_client): assert callable(context["apm"]["span_id"]) -@pytest.mark.parametrize("flask_apm_client", [{"logging": True}], indirect=True) -def test_logging_enabled(flask_apm_client): - logger = logging.getLogger() - logger.error("test") - error = flask_apm_client.client.events[ERROR][0] - assert error["log"]["level"] == "error" - assert error["log"]["message"] == "test" - - -@pytest.mark.parametrize("flask_apm_client", [{"logging": False}], indirect=True) -def test_logging_disabled(flask_apm_client): - logger = logging.getLogger() - logger.error("test") - assert len(flask_apm_client.client.events[ERROR]) == 0 - - -@pytest.mark.parametrize("flask_apm_client", [{"logging": logging.ERROR}], indirect=True) -def test_logging_by_level(flask_apm_client): - logger = logging.getLogger() - logger.warning("test") - logger.error("test") - assert len(flask_apm_client.client.events[ERROR]) == 1 - error = flask_apm_client.client.events[ERROR][0] - assert error["log"]["level"] == "error" - - def test_flask_transaction_ignore_urls(flask_apm_client): resp = flask_apm_client.app.test_client().get("/users/") resp.close()