aboutsummaryrefslogtreecommitdiffstats
path: root/arthur/log.py
blob: c382479e4f2ffd8aeefcdfdaa4b38ad7ab4ecd0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from functools import partial

import loguru
import sentry_sdk
from sentry_sdk.integrations.loguru import LoggingLevels, LoguruIntegration

from arthur.config import CONFIG, GIT_SHA

logger = loguru.logger.opt(colors=True)
logger.opt = partial(logger.opt, colors=True)


def setup_sentry() -> None:
    """Set up the Sentry logging integrations."""
    loguru_integration = LoguruIntegration(
        level=LoggingLevels.DEBUG.value, event_level=LoggingLevels.WARNING.value
    )

    sentry_sdk.init(
        dsn=CONFIG.sentry_dsn,
        integrations=[
            loguru_integration,
        ],
        release=f"king-arthur@{GIT_SHA}",
        traces_sample_rate=0.5,
        profiles_sample_rate=0.5,
    )