1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

Truncate Log lines (#4003)

This commit is contained in:
Dhrumil Shah 2023-09-06 16:53:11 -04:00 committed by GitHub
parent 15bfceb05a
commit e1eae00b35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -148,7 +148,7 @@ class AppLogPage extends HookConsumerWidget {
),
),
TextSpan(
text: logMessage.message,
text: truncateLogMessage(logMessage.message, 4),
style: const TextStyle(
fontSize: 14.0,
),
@ -170,4 +170,14 @@ class AppLogPage extends HookConsumerWidget {
),
);
}
/// Truncate the log message to a certain number of lines
/// @param int maxLines - Max number of lines to truncate
String truncateLogMessage(String message, int maxLines) {
List<String> messageLines = message.split("\n");
if (messageLines.length < maxLines) {
return message;
}
return "${messageLines.sublist(0, maxLines).join("\n")} ...";
}
}