Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ format:
tox-test:
@sh ./scripts/runtox.sh
.PHONY: tox-test

lint:
@tox -e linters
.PHONY: lint
4 changes: 1 addition & 3 deletions sentry_sdk/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

from ._compat import with_metaclass
from .scope import Scope
from .utils import exc_info_from_error, event_from_exception, get_logger, ContextVar
from .utils import exc_info_from_error, event_from_exception, logger, ContextVar


_local = ContextVar("sentry_current_hub")

logger = get_logger(__name__)


@contextmanager
def _internal_exceptions():
Expand Down
13 changes: 6 additions & 7 deletions sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import print_function

import sys
from threading import Lock

from ..utils import logger


_installer_lock = Lock()
_installed_integrations = {}
Expand Down Expand Up @@ -41,10 +40,10 @@ def __call__(self):
assert self.identifier
with _installer_lock:
if self.identifier in _installed_integrations:
print(
"warning: %s integration for Sentry is already "
"configured. Will ignore second configuration." % self.identifier,
file=sys.stderr,
logger.warning(
"%s integration for Sentry is already "
"configured. Will ignore second configuration.",
self.identifier,
)
return

Expand Down
9 changes: 8 additions & 1 deletion sentry_sdk/integrations/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
from . import Integration


IGNORED_LOGGERS = set(["sentry_sdk.errors"])


def ignore_logger(name):
IGNORED_LOGGERS.add(name)


class LoggingIntegration(Integration):
identifier = "logging"

Expand Down Expand Up @@ -43,7 +50,7 @@ def emit(self, record):
return self._emit(record)

def can_record(self, record):
return not record.name.startswith("sentry_sdk")
return record.name not in IGNORED_LOGGERS

def _breadcrumb_from_record(self, record):
return {
Expand Down
4 changes: 0 additions & 4 deletions sentry_sdk/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import io
import urllib3
import logging
import threading
import certifi
import sys
Expand All @@ -22,9 +21,6 @@
from urllib import getproxies


logger = logging.getLogger(__name__)


def _make_pool(parsed_dsn, http_proxy, https_proxy):
proxy = https_proxy if parsed_dsn == "https" else http_proxy
if not proxy:
Expand Down
10 changes: 4 additions & 6 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,10 @@ def strip_string(value, assume_length=None, max_length=512):
return value[:max_length]


def get_logger(name):
rv = logging.getLogger(name)
if not rv.handlers:
rv.addHandler(logging.StreamHandler(sys.stderr))
rv.setLevel(logging.DEBUG)
return rv
logger = logging.getLogger("sentry.errors")
if not logger.handlers:
logger.addHandler(logging.StreamHandler(sys.stderr))
logger.setLevel(logging.DEBUG)


try:
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ commands =

[testenv:linters]
commands =
flake8
black --check .
flake8 tests sentry_sdk
black --check tests sentry_sdk