Sepia::PerFileEventLogger
Inherits Sepia::EventLoggerBackend < Reference < Object
Event logging backend that stores one file per object.
This is the default implementation that creates a separate JSON Lines file for each object, containing all events for that object in chronological order.
File Structure
storage_path/
├── Document/ # Regular object storage
└──.events/ # Event storage
└── Document/
└── doc - 123.jsonl # Events for doc-123
Event Format
Each line in the file is a JSON object:
{"ts":"2025-01-15T10:30:45Z","type":"created","gen":1,"meta":{}}
{"ts":"2025-01-15T11:15:22Z","type":"updated","gen":2,"meta":{"user":"alice"}}
Constructors
Instance methods
Append an event to the object's event file.
Creates the event file and directory structure if needed, then appends the event as a JSON line.
Parameters
- object : The Sepia object the event relates to
- event_type : Type of event (Created, Updated, Deleted)
- generation : Object generation number
- metadata : Optional metadata for the event
The base storage path for events.
This is automatically detected from the current storage backend.
The base storage path for events.
This is automatically detected from the current storage backend.
Read all events for a specific object from its event file.
Returns an empty array if the file doesn't exist or no events are found.
Parameters
- object_class : The class of the object
- id : The object's unique identifier
Returns
Array of events for the specified object, ordered by timestamp