In Sentry Python SDK version 1.23.0 we introduced support for Loguru.
Example usage (see the documentation to learn more):
import sentry_sdk
from sentry_sdk.integrations.loguru import LoguruIntegration
# Add the Loguru integration
sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
LoguruIntegration(),
],
)
# Capture errors and exceptions:
from loguru import logger
logger.debug("I am ignored")
logger.info("I am a breadcrumb")
logger.error("I am an event", extra=dict(bar=43))
logger.exception("An exception happened")
What will happen:
An error event with the message "I am an event"
will be created.
"I am a breadcrumb"
will be attached as a breadcrumb to that event.
bar
will end up in the extra
attributes of that event.
"An exception happened"
will send the current exception from sys.exc_info()
with the stack trace to Sentry. If there's no exception, the current stack will be attached.
The debug message "I am ignored"
will not be captured by Sentry. To capture it, set level
to DEBUG
or lower in LoguruIntegration
.