logAllData method

Future<void> logAllData(
  1. Timer timer
)

Logs all the data saved in batchedLogs and resets it.

Implementation

Future<void> logAllData(Timer timer) async {
  for (final name in batchedLogs.keys) {
    final file = loggingDir / "$name.log";
    final data = batchedLogs[name]!;
    final copy = List<WrappedMessage>.from(data);
    data.clear();
    for (final wrapper in copy) {
      final encoded = base64.encode(wrapper.writeToBuffer());
      await file.writeAsString("$encoded\n", mode: FileMode.writeOnlyAppend);
    }
  }
}