As reported: SentinelOne Senior Software Engineer (Bengaluru), 2026, round 3 (low-level design): design and implement a Logger library that can store logs and retrieve logs and is thread-safe, then discuss the design and the concurrency choices.
Design and implement a Logger library. Application threads call it to record log entries; other code reads the entries back. Many threads log at the same time, so the library must be thread-safe. Agree on scope with your interviewer first: what a record holds, how logs are retrieved, and what "thread-safe" must guarantee.
Practice interface (one reasonable scope, used by the code runner):
Logger()creates an empty logger.int log(int timestamp, String level, String source, String message)stores a record and returns its id:1, 2, 3, …in the orderlogis called.levelis one ofDEBUG < INFO < WARN < ERROR.List<String> query(int start, int end, String minLevel)returns the records withstart <= timestamp <= endand a level at leastminLevel, ordered by timestamp, then by id. Each line is"<timestamp> <LEVEL> <source>: <message>".List<String> tail(int n)returns the lastnrecords by id (oldest of them first), or all of them if there are fewer.
Example
["Logger","log","log","log","log","query","query","tail"]
[[],[100,"INFO","auth","user login"],[105,"ERROR","db","connection lost"],
[102,"DEBUG","auth","token refreshed"],[110,"WARN","api","slow response"],
[100,106,"DEBUG"],[100,200,"WARN"],[2]]
Output: [null,1,2,3,4,
["100 INFO auth: user login","102 DEBUG auth: token refreshed","105 ERROR db: connection lost"],
["105 ERROR db: connection lost","110 WARN api: slow response"],
["102 DEBUG auth: token refreshed","110 WARN api: slow response"]]
The record with timestamp 102 arrived after the one with 105 (a slower thread), but query still returns it in time order; tail follows arrival order.
Constraints: at most 2,000 calls; 0 <= timestamp <= 10^6; timestamps may arrive out of order; sources are short words; messages are at most 40 printable characters.
Code runner format: two JSON lines, the method names and their arguments (LeetCode's design-problem format); the output is the list of return values with null for the constructor. Go uses Constructor() and the methods Log, Query, Tail.