shouldRollNextFile method

  1. @override
bool shouldRollNextFile()
override

Return true if log file should rotate to new.

Implementation

@override
bool shouldRollNextFile() {
  var now = DateTime.now();
  // little math to get NOW time based on timespan interval.
  var nowFlooredToTimeSpan = DateTime.fromMillisecondsSinceEpoch(
      now.millisecondsSinceEpoch -
          (now.millisecondsSinceEpoch % (timeSpan * 1000)).toInt());
  if (fileNameFormatter.format(nowFlooredToTimeSpan) !=
      fileNameFormatter.format(_currentFileDate)) {
    _currentFileDate = nowFlooredToTimeSpan;
    return true;
  }
  return false;
}