Extended handler interface for handlers that support log storage and retrieval

Handlers like memory and IndexedDB implement this interface to allow querying and exporting stored logs.

Remarks

Implementations should respect the configured retention policies (maxEntries and maxAge) to prevent unbounded growth. These limits can be changed at runtime to dynamically adjust retention behavior.

For high-volume logging, consider batching writes to reduce overhead.

Example

class MemoryHandler implements LogStore {
maxEntries = 10000;
maxAge = 7 * 24 * 60 * 60 * 1000; // 7 days

handle(entry: LogEntry): void { }
getLogs(): LogEntry[] { return []; }
clear(): void { }
}

Hierarchy

Properties

maxAge?: number

Maximum age of log entries in milliseconds

Entries older than this age should be removed during cleanup. If not specified, no age-based cleanup is performed.

This can be changed at runtime to dynamically adjust retention.

Example

// Retain logs for 7 days
store.maxAge = 7 * 24 * 60 * 60 * 1000;

// Retain logs for 1 hour
store.maxAge = 60 * 60 * 1000;
maxEntries?: number

Maximum number of log entries to retain

When the number of stored entries exceeds this limit, the oldest entries should be removed. If not specified, no entry-count limit is enforced.

This can be changed at runtime to dynamically adjust retention.

minLevel?: LogLevel

Minimum log level this handler should receive

If specified, the factory will only pass log entries with a level equal to or higher than this value. If not specified, all log entries are passed to the handler.

Level priority (lowest to highest): Debug → Info → Warn → Error

This can be changed at runtime to dynamically adjust filtering.

Methods

  • Clears all stored log entries

    Returns void | Promise<void>

  • Handles a log entry

    Implementations should handle their own errors internally to ensure reliability. However, any uncaught errors thrown by this method will be caught by the factory to prevent one handler from breaking others. Errors will be logged to the console but will not stop other handlers from receiving the log entry.

    Parameters

    • entry: LogEntry

      The log entry to handle

    Returns void | Promise<void>