add method

void add(
  1. String message, {
  2. DateTime? timestamp,
})

Add a log message with an optional timestamp.

If the buffer is at capacity the oldest entry is evicted.

Implementation

void add(String message, {DateTime? timestamp}) {
  if (_entries.length >= capacity) {
    _entries.removeFirst();
  }
  _entries.addLast(
    LogEntry(message: message, timestamp: timestamp ?? DateTime.now()),
  );
}