|
1 | | -import logging |
| 1 | +def init_sentry(*, enabled: bool = False, exclude_errors: bool = False) -> None: |
| 2 | + if not enabled: |
| 3 | + return |
2 | 4 |
|
3 | | -import sentry_sdk |
4 | | -from sentry_sdk.integrations.logging import LoggingIntegration |
5 | | -from sentry_sdk.integrations.stdlib import StdlibIntegration |
| 5 | + import logging |
6 | 6 |
|
| 7 | + import sentry_sdk |
| 8 | + from sentry_sdk.integrations.logging import LoggingIntegration |
| 9 | + from sentry_sdk.integrations.stdlib import StdlibIntegration |
7 | 10 |
|
8 | | -def init_sentry(*, enabled: bool = False, exclude_errors: bool = False) -> None: |
9 | | - if enabled: |
10 | | - sentry_logging = LoggingIntegration( |
11 | | - level=logging.INFO, # Capture info and above as breadcrumbs |
12 | | - event_level=logging.CRITICAL # Send only fatal errors as events if exclude_errors is True |
13 | | - if exclude_errors |
14 | | - else logging.ERROR, # Otherwise, error logs will create sentry events |
15 | | - ) |
| 11 | + sentry_logging = LoggingIntegration( |
| 12 | + level=logging.INFO, # Capture info and above as breadcrumbs |
| 13 | + event_level=logging.CRITICAL # Send only fatal errors as events if exclude_errors is True |
| 14 | + if exclude_errors |
| 15 | + else logging.ERROR, # Otherwise, error logs will create sentry events |
| 16 | + ) |
16 | 17 |
|
17 | | - sentry_sdk.init( |
18 | | - dsn="https://4b9a1902f9361b48c04376df6483bc96@o4506833230561280.ingest.sentry.io/4506833262477312", |
19 | | - integrations=[sentry_logging], |
20 | | - disabled_integrations=[StdlibIntegration], |
21 | | - traces_sample_rate=0, |
22 | | - profiles_sample_rate=0, |
23 | | - ignore_errors=[KeyboardInterrupt], |
24 | | - ) |
| 18 | + sentry_sdk.init( |
| 19 | + dsn="https://4b9a1902f9361b48c04376df6483bc96@o4506833230561280.ingest.sentry.io/4506833262477312", |
| 20 | + integrations=[sentry_logging], |
| 21 | + disabled_integrations=[StdlibIntegration], |
| 22 | + traces_sample_rate=0, |
| 23 | + profiles_sample_rate=0, |
| 24 | + ignore_errors=[KeyboardInterrupt], |
| 25 | + ) |
0 commit comments