Events & Logging
Events are the core building block of LogVault. Every action in your application that needs to be audited becomes an event.
What is an Event?
An event is a record of something that happened in your application. It captures who did what, when, and with what context. Events are:
- Immutable - Once created, they cannot be changed
- Timestamped - Automatically recorded with server time
- Signed - Cryptographically verified for integrity
- Searchable - Indexed for fast retrieval
Event Structure
Every event has these core fields:
JSON
1{2 "id": "evt_8f92a3b4c5d6e7f8",3 "action": "user.login",4 "actor_id": "user_123",5 "actor_type": "user",6 "target_id": "session_456",7 "target_type": "session",8 "timestamp": "2025-11-28T12:00:00Z",9 "metadata": {10 "ip_address": "82.10.22.1",11 "user_agent": "Mozilla/5.0...",12 "location": "Amsterdam, NL"13 },14 "signature": "sha256:a1b2c3d4..."15}
Required vs Optional Fields
| Field | Required | Description |
|---|---|---|
action | Yes | What happened (e.g., "user.login") |
actor_id | Yes | Who performed the action |
target_id | No | What was affected |
metadata | No | Additional context (JSON object) |
Action Naming Convention
We recommend using a resource.action format for your action names. This makes filtering and searching much easier:
user.login/user.logoutdocument.created/document.deletedpayment.processed/payment.failedsettings.updatedapi_key.rotated
Logging an Event
Here's how to log an event with our Python SDK:
Python
1import logvault23client = logvault.Client("lv_live_...")45# Simple event6client.log(7 action="user.login",8 actor_id="user_123"9)1011# Event with full context12client.log(13 action="document.exported",14 actor_id="user_123",15 target_id="doc_456",16 target_type="document",17 metadata={18 "format": "pdf",19 "file_size": 1024000,20 "ip_address": request.ip21 }22)
Best Practices
- Be specific with actions - Use
invoice.paidinstead of justupdate - Include relevant metadata - IP addresses, user agents, and request IDs help with investigations
- Don't log PII directly - Let LogVault's automatic scrubbing handle sensitive data
- Use consistent actor IDs - Always use the same ID format for the same user across events