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.
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 anException object to error(), the SDK extracts structured fields:
Data Object
Thedata 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: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 usingmin_level configuration, filtered logs don’t increment the step index:
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:
| Parameter | Type | Description |
|---|---|---|
body | str | The raw log data |
format | FormatName | One of json, jsonl, syslog, text, csv, obl |
options? | IngestRawOptions | Optional defaults for source, environment, level, dataset |
Content-Type header automatically and retries with exponential backoff on failure.
Examples
CSV:Supported Formats
| Format | Content-Type | Description |
|---|---|---|
json | application/json | JSON array or { logs: [...] } |
jsonl | application/x-ndjson | One JSON object per line |
syslog | application/x-syslog | RFC 5424 / RFC 3164 |
text | text/plain | One log per line |
csv | text/csv | Header row + data rows |
obl | application/x-obl | Open Board Logging |
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 returnself for chaining:
Log Entry Dataclass
Options Object
All logging methods accept an optionaloptions 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