Skip to main content

Installation

Basic Usage

Exports

The SDK exports the following:

Logging Methods

debug(message, data?, options?)

Log debug-level messages for detailed diagnostic information.

info(message, data?, options?)

Log informational messages about normal operations.

warn(message, data?, options?)

Log warning conditions that might indicate a problem.

error(message, errorOrData?, options?)

Log errors. Accepts either an Exception object or a data dictionary.
When you pass an Exception object, the SDK automatically extracts:
  • errorName — The exception’s class name (e.g. ValueError)
  • errorStack — The full traceback
  • The exception message is included in the data

log(entry)

Low-level logging method with full control over the log entry.

Error Handling

When you pass an Exception object to error(), the SDK extracts structured fields:

Data Object

The data parameter accepts any JSON-serializable dictionary:

Tags

Tags help categorize and filter logs. Add them via the options parameter:

Flow Tracking

Flows group related logs across a multi-step process with automatic flow IDs and step indexing. See Flows for a conceptual overview.

Creating a Flow

Synchronous — generates a local flow ID:
Asynchronous — creates the flow on the server for a server-generated ID:
Both produce logs with:
  • flowId: "checkout-a1b2c3d4" (auto-generated)
  • stepIndex: 0, 1, 2, 3 (auto-incrementing)

Flow Properties

Flow Logging Methods

Flows have the same logging methods as the main client:

Flow Chaining

Flow methods return the flow for chaining:

Real-World Examples

Data Pipeline

Flow ID Generation

Flow IDs are generated using the pattern: {name}-{random8chars}

Level Filtering with Flows

When using min_level configuration, filtered logs don’t increment the step index:
This ensures your step indices remain sequential without gaps.

Raw Format Ingestion

Send pre-formatted log data directly to the ingestion endpoint, bypassing the structured log pipeline. Useful for forwarding logs from external systems (syslog daemons, CSV exports, JSONL streams).

ingest_raw(body, format, options?)

Synchronous version:

ingest_raw_async(body, format, options?) (async)

Asynchronous version:
Parameters: The SDK sets the correct Content-Type header automatically and retries with exponential backoff on failure.

Examples

CSV:
JSONL:
Plain text:

Supported Formats

See Log Ingestion for full format details.

Client Methods

set_user_id(user_id)

Set the default user ID for subsequent logs.

set_session_id(session_id)

Set the default session ID for subsequent logs.

flush()

Immediately send all queued logs.

flush_async() (async)

Asynchronously send all queued logs.

disconnect()

Flush logs and stop the auto-flush timer.

disconnect_async() (async)

Asynchronously flush and stop the client.

Method Chaining

All methods return self for chaining:

Log Entry Dataclass

Options Object

All logging methods accept an optional options object:

Context Manager

Use the client as a context manager for automatic cleanup:

Async Context Manager

Configuration

Requirements

  • Python 3.8+
  • httpx >= 0.24.0
Ready to start logging? Sign up free — send your first log in under 5 minutes.