toConsole method
Generate console-friendly output.
Implementation
String toConsole() {
final buffer = StringBuffer();
// Status line
if (summary.exceedsThreshold) {
buffer.writeln('DEBT THRESHOLD EXCEEDED');
}
buffer.writeln(
'Total: ${summary.totalCost.toStringAsFixed(1)} ${summary.unit} '
'(threshold: ${summary.threshold.toStringAsFixed(1)} ${summary.unit})');
buffer.writeln('Items: ${summary.itemCount}');
buffer.writeln();
// Top types
buffer.writeln('By Type:');
for (final typeSummary in summary.typesByHighestCost.take(5)) {
if (typeSummary.count > 0) {
buffer.writeln(
' ${typeSummary.type.label}: ${typeSummary.count} items '
'(${typeSummary.cost.toStringAsFixed(1)} ${summary.unit})');
}
}
buffer.writeln();
// Hotspots
final hotspots = getHotspots(5);
if (hotspots.isNotEmpty) {
buffer.writeln('Hotspots:');
for (final file in hotspots) {
buffer.writeln(
' ${file.filePath}: ${file.itemCount} items '
'(${file.totalCost.toStringAsFixed(1)} ${summary.unit})');
}
}
return buffer.toString();
}