flush method

void flush()

Flush buffered logs to file.

Implementation

void flush() {
  if (_buffer.isNotEmpty) {
    try {
      // Ensure parent directory exists
      if (!_logFile.parent.existsSync()) {
        _logFile.parent.createSync(recursive: true);
      }
      _logFile.writeAsStringSync(
        '${_buffer.join('\n')}\n',
        mode: FileMode.append,
      );
      _buffer.clear();
    } catch (e) {
      // Silently fail to avoid breaking plugin
    }
  }
}