Skip to main content
If your service already uses Python’s built-in logging module, add SquasherHandler to forward log records to Squasher without replacing the rest of your logging setup.

Installation

Configuration

Create a handler once, attach it to your logger, and keep the rest of your logging pipeline unchanged.
app/logging.py
The handler sends events on a background thread, so logger.error() does not block while the HTTP request is in flight.

Usage Example

app/main.py
Call flush() and close() during shutdown to make sure queued log records are delivered before the process exits.

Exception Handling

Use logger.exception() inside an except block to include the exception type and traceback automatically.
When exc_info is present, the handler sends both the exception type and the formatted stack trace alongside the log message, so the error shows up in Squasher with full debugging context.

Structured attributes

Pass typed context through extra. The handler preserves numbers and booleans, redacts sensitive attribute names, and reads trace_id and span_id for correlation.
SamplingConfig keeps errors and slow records by default. A stable trace gets one sampling decision.

Agent handoff