You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be nice to have logs of different levels be colored appropriately.
Idea for implementation below (it was actually my take at it but I didn't have time to debug & finish it)
/// Instructs [LoggingBugfenderListener] to print colored text./// The color is based on the log level.classColoredTextPrintStrategyextendsPrintStrategy {
/// Creates a strategy that prints colored plain text.constColoredTextPrintStrategy();
staticfinal _levelColors =<Level, String?>{
Level.FINEST:'8',
Level.FINER:'8',
Level.FINE:'8',
Level.CONFIG:null,
Level.INFO:'12',
Level.WARNING:'208',
Level.SEVERE:'196',
Level.SHOUT:'199',
};
@overrideStringprint(LogRecord record) {
final log =StringBuffer()
..writeAll(
<String>[
'[${record.level.name}]',
if (record.loggerName.isNotEmpty) '${record.loggerName}:',
record.message,
],
' ',
);
if (record.error !=null) {
log.write('\n${record.error}');
}
if (record.stackTrace !=null) {
log.write('\n${record.stackTrace}');
}
final color = _levelColors[record.level];
if (color !=null) {
return'\x1B[${color}m$log\x1B[0m';
} else {
return log.toString();
}
}
}
The text was updated successfully, but these errors were encountered:
It'd be nice to have logs of different levels be colored appropriately.
Idea for implementation below (it was actually my take at it but I didn't have time to debug & finish it)
The text was updated successfully, but these errors were encountered: