mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Log app crash exceptions in dumped crash logs (#742)
This commit is contained in:
parent
80461d883f
commit
a3d438e2f5
2 changed files with 3 additions and 2 deletions
|
@ -37,7 +37,7 @@ fun CrashScreen(
|
|||
acceptText = stringResource(MR.strings.pref_dump_crash_logs),
|
||||
onAcceptClick = {
|
||||
scope.launch {
|
||||
CrashLogUtil(context).dumpLogs()
|
||||
CrashLogUtil(context).dumpLogs(exception)
|
||||
}
|
||||
},
|
||||
rejectText = stringResource(MR.strings.crash_screen_restart_application),
|
||||
|
|
|
@ -19,12 +19,13 @@ class CrashLogUtil(
|
|||
private val extensionManager: ExtensionManager = Injekt.get(),
|
||||
) {
|
||||
|
||||
suspend fun dumpLogs() = withNonCancellableContext {
|
||||
suspend fun dumpLogs(exception: Throwable? = null) = withNonCancellableContext {
|
||||
try {
|
||||
val file = context.createFileInCacheDir("mihon_crash_logs.txt")
|
||||
|
||||
file.appendText(getDebugInfo() + "\n\n")
|
||||
getExtensionsInfo()?.let { file.appendText("$it\n\n") }
|
||||
exception?.let { file.appendText("$it\n\n") }
|
||||
|
||||
Runtime.getRuntime().exec("logcat *:E -d -f ${file.absolutePath}").waitFor()
|
||||
|
||||
|
|
Loading…
Reference in a new issue