Log Ring with Timestamps
Implement a bounded in-memory log that keeps the most recent N entries with monotonic timestamps, and can dump them oldest-first for a crash report.
Constraints
- Fixed capacity given at construction.
- Adding to a full log evicts the oldest entry.
- Timestamps come from a supplied clock function so tests are deterministic.
- dump() returns entries oldest-first regardless of internal wrap.
- Must not use collections.deque.
- O(1) append.
1class LogRing:2 def __init__(self, capacity, clock):3 pass4 5 def append(self, message):6 pass7 8 def dump(self):9 return []