add full crash logcat report

This commit is contained in:
Kr328 committed 2020-04-23 00:12:07 +08:00
1 parent 4417a85ef7
commit 75de6ce041
2 files changed
+6 -20

No files matched your search

@@ -42,7 +42,7 @@ class MainApplication : Application() {
if (!report.stackTrace.contains("DeadObjectException"))
return mutableListOf()
val logcat = LogcatDumper.dump().joinToString(separator = "\n")
val logcat = LogcatDumper.dump()
return mutableListOf(
ErrorAttachmentLog.attachmentWithText(logcat, "logcat.txt")
@@ -1,34 +1,20 @@
package com.github.kr328.clash.dump
object LogcatDumper {
fun dump(): List<String> {
fun dump(): String {
return try {
val process =
Runtime.getRuntime().exec(arrayOf("logcat", "-d", "-s", "-v", "raw", "Go", "AndroidRuntime"))
Runtime.getRuntime().exec(arrayOf("logcat", "-d", "-s", "-v", "raw", "Go", "AndroidRuntime", "DEBUG"))
val result = process.inputStream.bufferedReader().useLines {
var list = mutableListOf<String>()
var capture = false
it.forEach { line ->
if (line.startsWith("panic")) {
capture = true
list = mutableListOf()
}
if (capture)
list.add(line)
}
list
val result = process.inputStream.use {
it.reader().readText()
}
process.waitFor()
result
} catch (e: Exception) {
emptyList()
""
}
}
}