change the output of logcat to not file

This commit is contained in:
altalk23 committed 2023-10-15 17:13:42 +03:00
1 parent 2500a39133
commit 634c0bc56a
1 file changed
+5 -24
@@ -71,36 +71,17 @@ object GeodeUtils {
} }
@JvmStatic @JvmStatic
fun clearLogcatCrashBuffer(): Boolean { fun getLogcatCrashBuffer(path: String): String {
try {
val logcatProcess = Runtime.getRuntime().exec("logcat -c -b crash")
return true
}
catch (e: Exception) {
Log.e("Geode", "Failed to clear logcat crash buffer", e)
return false
}
}
@JvmStatic
fun writeLogcatCrashBuffer(path: String): Boolean {
try { try {
val logcatProcess = Runtime.getRuntime().exec("logcat -v brief -b crash -d") val logcatProcess = Runtime.getRuntime().exec("logcat -v brief -b crash -d")
val logcatFile = File(path) val logcatOutput = logcatProcess.inputStream.bufferedReader().readText()
logcatFile.outputStream().use { output -> return logcatOutput
logcatProcess.inputStream.use { input ->
input.copyTo(output)
}
}
return true
} }
catch (e: Exception) { catch (e: Exception) {
Log.e("Geode", "Failed to write logcat crash buffer", e) Log.e("Geode", "Failed to get logcat crash buffer", e)
return false return ""
} }
} }