Preparing your design workspace

Loading the problem and your saved attempt…

Design a Thread-Safe Queryable Logger Library

Model concurrent structured-log appends and filtered retrieval with stable ordering and snapshot semantics.

Design and implement a logger library that stores logs, retrieves them, and remains safe when multiple threads use it concurrently. For this exercise, assume clients append structured entries with exactly one fixed INFO, WARN, or ERROR level, a non-empty category and message, and optional string context fields.

The library assigns each accepted entry a timestamp from an injected clock and a monotonic sequence number. Callers query an inclusive time range with optional level and category filters; results are ordered by sequence and returned as an immutable snapshot chosen at one documented observation point.

An invalid time range, unsupported level, empty category, or empty message is rejected before shared state changes, and any failed append stores no partial entry or consumed sequence. Keep the library in memory and in one process.

File or console sinks, formatting plugins, remote delivery, runtime configuration, background dispatch, and baseline retention eviction are out of scope.