Audit logging for AI agents.
This crate provides comprehensive audit logging for all tool calls, LLM requests, and agent lifecycle events. It supports multiple backends and is designed for compliance and debugging in production environments.
Features
- Structured Events: Rich event types for tool calls, LLM requests, errors, and more
- Multiple Backends: File, JSON, and async logging with rotation support
- Configurable Levels: Filter events by severity (Debug, Info, Warn, Error, Critical)
- Log Rotation: Size-based, daily, or hourly rotation with cleanup
- Non-blocking: Async wrapper for high-throughput scenarios
- Compliance Ready: Designed for GDPR, SOC2, and enterprise requirements
Quick Start
use ;
# async
Event Types
The crate supports various event types through EventKind:
ToolCall: Tool invocations with parameters and resultsLlmRequest: Outgoing LLM API requestsLlmResponse: Incoming LLM responsesAgentLifecycle: Agent start, stop, pause, resume eventsApprovalDecision: Human-in-the-loop approval decisionsError: Error events with stack tracesSecurity: Security-related events (auth, rate limits)Custom: Extensible custom events
Backends
FileLogger
Simple human-readable text format, good for development.
JsonFileLogger
Structured JSON Lines format with rotation, ideal for production.
AsyncLogger
Non-blocking wrapper around any logger for high-throughput scenarios.
MemoryLogger
In-memory storage for testing.
CompositeLogger
Writes to multiple backends simultaneously.
Configuration
use ;
// Development config - verbose logging
let dev_config = development;
// Production config - info level with redaction
let prod_config = production;
// Custom config
let custom_config = new
.with_min_level
.with_redaction
.with_max_payload_size;