Installation
Basic Usage
Exports
The crate exports the following:Logging Methods
debug(message, data)
Log debug-level messages for detailed diagnostic information.
info(message, data)
Log informational messages about normal operations.
warn(message, data)
Log warning conditions that might indicate a problem.
error(message, data)
Log errors.
log(entry)
Low-level logging method with full control over the log entry.
Error Handling
All async methods returnResult<(), TimberlogsError>:
Data Object
Thedata parameter accepts Option<HashMap<String, serde_json::Value>>:
Tags
Tags help categorize and filter logs. Add them via theLogEntry:
Flow Tracking
Flows group related logs across a multi-step process with automatic flow IDs and step indexing.Creating a Flow
Use theflow() method to create a new flow. This is an async operation that creates the flow on the server:
flow_id(server-generated)step_index: 0, 1, 2, 3(auto-incrementing)
Flow Properties
Flow Logging Methods
Flows have the same logging methods as the main client:Custom Level and Tags
Uselog_with_level for full control:
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.ingest_raw(body, format, options)
| Parameter | Type | Description |
|---|---|---|
body | impl Into<String> | The raw log data |
format | RawFormat | One of Json, Jsonl, Syslog, Text, Csv, Obl |
options | Option<IngestRawOptions> | Optional defaults for source, environment, level, dataset |
Examples
CSV:Supported Formats
| Format | Content-Type | Description |
|---|---|---|
Json | application/json | JSON array or object |
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 |