printLogHandler function
The SpringLog.handler used until a logging backend replaces it:
writes each record as one line, [logger] LEVEL: message, to
standard output on the Dart VM, to the device log in Flutter and to
the browser's console on the web.
The error follows the message; the stack trace is not printed. In a terminal (printLogHandlerColours) the logger name is cyan and the level coloured by level (error red, warning yellow, the others green), as Spring Boot's console colours its lines when it detects one. Written to a file or a pipe, in Flutter (the device log) and on the web (the browser's console) the line is plain text.
Implementation
void printLogHandler(SpringLogRecord record) {
final error = record.error;
final name = record.level.name.toUpperCase();
final message = '${record.message}${error == null ? '' : ': $error'}';
if (!printLogHandlerColours) {
printLogHandlerOut('[${record.loggerName}] $name: $message');
return;
}
final level = switch (record.level) {
SpringLogLevel.error => '31',
SpringLogLevel.warning => '33',
_ => '32',
};
printLogHandlerOut(
'[\x1B[36m${record.loggerName}\x1B[0;39m] '
'\x1B[${level}m$name\x1B[0;39m: $message',
);
}