From e1eae00b353973afb003bb652d131a238948908b Mon Sep 17 00:00:00 2001 From: Dhrumil Shah Date: Wed, 6 Sep 2023 16:53:11 -0400 Subject: [PATCH] Truncate Log lines (#4003) --- mobile/lib/shared/views/app_log_page.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mobile/lib/shared/views/app_log_page.dart b/mobile/lib/shared/views/app_log_page.dart index 3d1fbfee71..a8dfc6ec44 100644 --- a/mobile/lib/shared/views/app_log_page.dart +++ b/mobile/lib/shared/views/app_log_page.dart @@ -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 messageLines = message.split("\n"); + if (messageLines.length < maxLines) { + return message; + } + return "${messageLines.sublist(0, maxLines).join("\n")} ..."; + } }