FileSink

class FileSink(val minLevel: LogLevel = LogLevel.INFO, maxLines: Int = 2000, includeTimestamps: Boolean = true) : LoggingSink

In-memory ring buffer logging sink with file persistence support.

Maintains a fixed-size circular buffer of log entries. Oldest entries are discarded when the buffer is full. Entries can be exported as formatted text.

Security (BSI APP.4.4.A3): Logs are stored in memory only and can be explicitly exported. No automatic disk persistence.

Thread Safety: Uses ConcurrentLinkedDeque for thread-safe operations.

Since

0.4.0

Constructors

Link copied to clipboard
constructor(minLevel: LogLevel = LogLevel.INFO, maxLines: Int = 2000, includeTimestamps: Boolean = true)

Types

Link copied to clipboard
data class BufferStatistics(val totalEntries: Int, val maxCapacity: Int, val levelBreakdown: Map<LogLevel, Int>, val oldestTimestamp: Long?, val newestTimestamp: Long?)

Statistics about the log buffer.

Properties

Link copied to clipboard
open override val minLevel: LogLevel

Minimum log level to accept

Functions

Link copied to clipboard
open fun accepts(level: LogLevel): Boolean

Check if this sink accepts entries at the given level.

Link copied to clipboard
fun clear()

Clear all buffered entries.

Link copied to clipboard
open fun close()

Close this sink and release resources.

Link copied to clipboard
open override fun emit(entry: LogEntry)

Emit a log entry to this sink.

Link copied to clipboard
fun entriesSince(sinceMs: Long): List<LogEntry>

Get entries since a given timestamp.

Link copied to clipboard
fun filter(minLevel: LogLevel? = null, tag: String? = null, correlationId: String? = null): List<LogEntry>

Get entries matching a filter.

Link copied to clipboard
open fun flush()

Flush any buffered entries.

Link copied to clipboard

Get formatted log as JSON array for structured export.

Link copied to clipboard
fun formatForExport(separator: String = ""): String

Get formatted log text for export.

Link copied to clipboard

Get all buffered log entries.

Link copied to clipboard

Get statistics about the buffer.

Link copied to clipboard
fun size(): Int

Get current buffer size.