Take Sentry SDK as a good example of such.
Capture errors
https://docs.sentry.io/platforms/python/#capturing-errors
from sentry_sdk import capture_exception
try:
a_potentially_failing_function()
except Exception as e:
# Alternatively the argument can be omitted
capture_exception(e)
Capture messages
https://docs.sentry.io/error-reporting/capturing/?platform=python#capturing-messages
from sentry_sdk import capture_message
capture_message('Something went wrong')
Extra context
https://docs.sentry.io/platforms/python/#extra-context
from sentry_sdk import configure_scope
with configure_scope() as scope:
scope.set_extra("character_name", "Mighty Fighter")
Take Sentry SDK as a good example of such.
Capture errors
https://docs.sentry.io/platforms/python/#capturing-errors
Capture messages
https://docs.sentry.io/error-reporting/capturing/?platform=python#capturing-messages
Extra context
https://docs.sentry.io/platforms/python/#extra-context