blob: 38d5526861c6dbe1a5775132c34f0e86e4692e8d [file]
/// Splits a raw multi-line log string into individual lines without changing
/// their content.
///
/// Handles both `\n` and `\r\n` line endings. A trailing line break is ignored
/// so log blocks ending with a newline do not render an extra empty row.
Iterable<String> splitLogLines(String rawLog) sync* {
if (rawLog.isEmpty) {
return;
}
final lines = rawLog.split(RegExp(r'\r?\n'));
final end = lines.isNotEmpty && lines.last.isEmpty ? lines.length - 1 : lines.length;
for (var i = 0; i < end; i++) {
yield lines[i];
}
}