FateLogWriter
A writer for FateWeaver log files that supports multiple typed channels.
FateLogWriter provides a high-performance binary logging format with the following features:
Type Safety: Each channel is strongly typed with compile-time guarantees
Schema Evolution: Schemas are embedded in the log file for compatibility
Multiple Channels: Different data types can be logged to separate named channels
Efficient Encoding: Binary format optimized for size and speed
Auto-Schema Detection: Can automatically infer schemas from class types
File Format
Each log file begins with a header containing magic bytes and version information, followed by a series of entries. There are two types of entries:
Schema Entries (type 0): Define the structure of a channel
Message Entries (type 1): Contain the actual logged data
Usage Example
// Create a log writer
FateLogWriter.create("mylog.fate").use { writer ->
// Create typed channels
val userChannel = writer.createChannel("users", User::class)
val eventChannel = writer.createChannel("events", Event::class)
// Write data
userChannel.put(User("alice", 25))
eventChannel.put(Event("login", System.currentTimeMillis()))
}Parameters
The output stream to write the log data to
Constructors
Types
Functions
Adds a channel to the log and immediately writes its schema definition.
Adds a channel to the log, creating a WriterChannel from the given LogChannel if necessary.
Checks if a channel with the same name as the provided channel exists in this writer.
Creates a new log channel with the specified name and schema, and adds it to the log.
Creates a new log channel with the specified name and automatically inferred schema.