shouldLog method

  1. @override
bool shouldLog(
  1. LogEntry entry
)
override

Determines if a log entry should be emitted based on sampling rules.

Implementation

@override
bool shouldLog(LogEntry entry) {
  final key = entry.category ?? 'default';
  final now = entry.timestamp;
  final times = _logTimes[key] ?? [];

  // Remove old entries outside the window
  final cutoff = now.subtract(window);
  times.removeWhere((time) => time.isBefore(cutoff));

  // Check if we're under the limit
  if (times.length < maxLogsPerWindow) {
    return true;
  }

  return false;
}