-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
31 lines (28 loc) · 1.04 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import 'dart:async';
import 'dart:convert';
import 'dart:developer' as dev;
import 'package:edna/player_journal/file_tailer.dart';
import 'package:edna/player_journal/journal_log_file.dart';
import 'package:edna/player_journal/player_journal.dart';
void main() async {
final ctrl = StreamController<PlayerJournalEventRecord>();
final journalLogFile = await currentJournalLogFile(playerJournalPath: PlayerJournal.localJournalPath());
if (journalLogFile == null) {
throw Exception('No Journal log file found.');
}
print('Journal log file: $journalLogFile');
final tailer = FileTailer(journalLogFile);
print('Using file: ${tailer.file.path}, exists: ${tailer.file.existsSync() ? "yes" : "no"}');
await tailer
.stream()
.transform(utf8.decoder)
.transform(LineSplitter())
.transform(PlayerJournalEventRecordDecoder())
.forEach((event) async {
print(event);
if (event.event == PlayerJournalShutdownEventRecord.type) {
await ctrl.close();
tailer.cancel();
}
});
}