gale.log.sentry_handler module

This file contains the implementation of the class SentryHandler: a logging.Handler that sends each log record to Sentry as an event through its HTTP Store API, using only the standard library.

Author: Alejandro Mujica (aledrums@gmail.com)

class gale.log.sentry_handler.SentryHandler(dsn, timeout=2.0)[source]

Bases: Handler

Sends every log record to Sentry (sentry.io or a self-hosted instance) as an event through its HTTP Store API, using only the standard library — no sentry-sdk dependency. It’s a lightweight “at least get pinged about errors” integration; for full Sentry features (breadcrumbs, releases, performance tracing, offline queuing/retry…) use sentry-sdk directly instead.

Usage example:

from gale.log import add_handler from gale.log.sentry_handler import SentryHandler

add_handler(SentryHandler(”https://<public_key>@<host>/<project_id>”))

Parameters:
  • dsn (str)

  • timeout (float)

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

Parameters:

record (LogRecord)

Return type:

None