Required Options
| Option | Type | Description |
|---|---|---|
source | String | Your application or service name. Used to filter logs. |
environment | Environment | Development, Staging, or Production. |
api_key | String | Your Timberlogs API key (starts with tb_live_ or tb_test_). |
Optional Options
| Option | Type | Default | Description |
|---|---|---|---|
version | Option<String> | None | Your application version (e.g., "1.2.3"). |
dataset | Option<String> | None | Default dataset for grouping/routing logs. |
user_id | Option<String> | None | Default user ID attached to all logs. |
session_id | Option<String> | None | Default session ID attached to all logs. |
batch_size | Option<usize> | 10 | Number of logs to batch before sending. Must be > 0. |
flush_interval_ms | Option<u64> | 5000 | Milliseconds between auto-flush. |
min_level | Option<LogLevel> | Debug | Minimum level to send (Debug, Info, Warn, Error). |
on_error | Option<ErrorCallback> | None | Called when background flush fails after all retries. |
retry | Option<RetryConfig> | See below | Retry configuration for failed requests. |
Retry Configuration
The SDK automatically retries failed requests with exponential backoff.Log Level Filtering
Usemin_level to filter out lower-priority logs:
Setting User/Session at Runtime
You can update the user and session IDs after initialization:Validation Limits
The SDK validates fields before sending. Logs that exceed these limits will return aTimberlogsError::Validation error.
| Field | Limit |
|---|---|
message | 1–10,000 characters |
error_name | Max 200 characters |
error_stack | Max 10,000 characters |
user_id, session_id, request_id | Max 100 characters each |
flow_id, dataset | Max 50 characters each |
ip_address | Max 100 characters |
country | Max 10 characters |
step_index | 0–1,000 |
tags | Max 20 items, 50 characters each |