From 0020c29426d248caf98c64a14e02cc02146dda3f Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 10 Nov 2022 23:13:09 +0000 Subject: [PATCH] logging inner error cause to the log output - also fixes log lines introducing blank lines due to a missing line height --- .../app/dapk/st/tracking/CrashTrackerLogger.kt | 13 +++++++++++++ .../dapk/st/settings/eventlogger/EventLogScreen.kt | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/domains/android/tracking/src/main/kotlin/app/dapk/st/tracking/CrashTrackerLogger.kt b/domains/android/tracking/src/main/kotlin/app/dapk/st/tracking/CrashTrackerLogger.kt index cd2a99d..b5eaea4 100644 --- a/domains/android/tracking/src/main/kotlin/app/dapk/st/tracking/CrashTrackerLogger.kt +++ b/domains/android/tracking/src/main/kotlin/app/dapk/st/tracking/CrashTrackerLogger.kt @@ -10,6 +10,19 @@ class CrashTrackerLogger : ErrorTracker { override fun track(throwable: Throwable, extra: String) { Log.e("ST", throwable.message, throwable) log(AppLogTag.ERROR_NON_FATAL, "${throwable.message ?: "N/A"} extra=$extra") + + throwable.findCauseMessage()?.let { + if (throwable.message != it) { + log(AppLogTag.ERROR_NON_FATAL, it) + } + } + } +} + +private fun Throwable.findCauseMessage(): String? { + return when (val inner = this.cause) { + null -> this.message ?: "" + else -> inner.findCauseMessage() } } diff --git a/features/settings/src/main/kotlin/app/dapk/st/settings/eventlogger/EventLogScreen.kt b/features/settings/src/main/kotlin/app/dapk/st/settings/eventlogger/EventLogScreen.kt index 50cbfee..51cbcff 100644 --- a/features/settings/src/main/kotlin/app/dapk/st/settings/eventlogger/EventLogScreen.kt +++ b/features/settings/src/main/kotlin/app/dapk/st/settings/eventlogger/EventLogScreen.kt @@ -107,10 +107,10 @@ private fun Events(selectedPageContent: SelectedState, onExit: () -> Unit, onSel null -> "${it.time}: ${it.tag}: ${it.content}" else -> "${it.time}: ${it.content}" } - Text( text = text, - modifier = Modifier.padding(horizontal = 4.dp), + lineHeight = 14.sp, + modifier = Modifier.padding(horizontal = 4.dp).fillMaxWidth(), fontSize = 10.sp, ) }