saveCacheLog function

void saveCacheLog(
  1. String html,
  2. bool debug
)

Implementation

void saveCacheLog(String html, bool debug) {
  if (!debug) return;

  // Ensure findRootDirectory is defined somewhere accessible
  String rootPath = findRootDirectory(Directory.current.path);
  try {
    int timestamp = DateTime.now().millisecondsSinceEpoch;

    File cache = File('$rootPath/cache/cache.html');
    String cacheHtml = cache.readAsStringSync();

    File file = File('$rootPath/cache/$timestamp.html');
    file.writeAsStringSync(cacheHtml);

    cache.writeAsStringSync(html, mode: FileMode.write);
  } catch (e) {
    printLog('Unable to save file to $rootPath/cache folder', debug,
        color: LogColor.red);
  }
}