initIOSink method

void initIOSink()

Initializes the IOSink for file writing.

This creates or opens the log file for appending.

Implementation

void initIOSink() {
  try {
    final logFile = File(logFilePath);
    // Create the file if it doesn't exist
    if (!logFile.existsSync()) {
      logFile.createSync(recursive: true);
    }
    fileIOSink = logFile.openWrite(mode: FileMode.append);
  } catch (e) {
    debugPrint('Error initializing log file: $e');
    // If we can't write to the file, we'll still allow console logging
    // but disable file logging to prevent crashes
    rethrow;
  }
}