From 8c072bde320d5439d4d99362f1f923c8e3095ec6 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Tue, 3 Sep 2019 11:09:14 +0200 Subject: [PATCH] fix: Include logging docs in new API docs --- docs/api.rst | 9 +++++++++ docs/index.rst | 8 +++----- docs/integrations.rst | 14 ++++++++++++++ sentry_sdk/integrations/logging.py | 20 ++++++++++++++++++-- 4 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 docs/api.rst create mode 100644 docs/integrations.rst diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000000..01bef3ee12 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,9 @@ +======== +Main API +======== + +.. inherited-members necessary because of hack for Client and init methods + +.. automodule:: sentry_sdk + :members: + :inherited-members: diff --git a/docs/index.rst b/docs/index.rst index 2722e0967c..ade1dc0da8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,8 +6,6 @@ This is the API documentation for `Sentry's Python SDK `_. For full documentation and other resources visit the `GitHub repository `_. -.. inherited-members necessary because of hack for Client and init methods - -.. automodule:: sentry_sdk - :members: - :inherited-members: +.. toctree:: + api + integrations diff --git a/docs/integrations.rst b/docs/integrations.rst new file mode 100644 index 0000000000..a04d99d660 --- /dev/null +++ b/docs/integrations.rst @@ -0,0 +1,14 @@ +============ +Integrations +============ + +Logging +======= + +.. module:: sentry_sdk.integrations.logging + +.. autofunction:: ignore_logger + +.. autoclass:: EventHandler + +.. autoclass:: BreadcrumbHandler diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py index e0a1455313..53564fd528 100644 --- a/sentry_sdk/integrations/logging.py +++ b/sentry_sdk/integrations/logging.py @@ -27,12 +27,16 @@ _IGNORED_LOGGERS = set(["sentry_sdk.errors"]) -def ignore_logger(name): - # type: (str) -> None +def ignore_logger( + name # type: str +): + # type: (...) -> None """This disables recording (both in breadcrumbs and as events) calls to a logger of a specific name. Among other uses, many of our integrations use this to prevent their actions being recorded as breadcrumbs. Exposed to users as a way to quiet spammy loggers. + + :param name: The name of the logger to ignore (same string you would pass to ``logging.getLogger``). """ _IGNORED_LOGGERS.add(name) @@ -146,6 +150,12 @@ def _extra_from_record(record): class EventHandler(logging.Handler, object): + """ + A logging handler that emits Sentry events for each log record + + Note that you do not have to use this class if the logging integration is enabled, which it is by default. + """ + def emit(self, record): # type: (LogRecord) -> Any with capture_internal_exceptions(): @@ -204,6 +214,12 @@ def _emit(self, record): class BreadcrumbHandler(logging.Handler, object): + """ + A logging handler that records breadcrumbs for each log record. + + Note that you do not have to use this class if the logging integration is enabled, which it is by default. + """ + def emit(self, record): # type: (LogRecord) -> Any with capture_internal_exceptions():