logData method
- Message message, {
- bool includeDuplicate = false,
Outputs log data to the correct file based on message
If includeDuplicate is set to false (default), then it will only write
the log to a file if it doesn't match the previously written log of the
message type
Implementation
Future<void> logData(Message message, {bool includeDuplicate = false}) async {
final batch = batchedLogs[message.messageName] ??= [];
final lastLog = lastWritten[message.messageName];
final wrapped = message.wrap();
if (includeDuplicate) {
batch.add(wrapped);
return;
}
// If the last queued log is the same data
if (batch.isNotEmpty && batch.last.data.equals(wrapped.data)) {
return;
} else if (batch.lastOrNull == null &&
lastLog != null &&
lastLog.data.equals(wrapped.data)) {
// If the last written log has the same data
return;
}
batch.add(wrapped);
}