mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-25 11:22:20 +00:00
add most recent log lines to crash reports
This commit is contained in:
parent
af957be561
commit
5f42d00bca
3 changed files with 6 additions and 3 deletions
|
@ -11,6 +11,7 @@ import android.os.Build
|
|||
import org.dslul.openboard.inputmethod.latin.BuildConfig
|
||||
import org.dslul.openboard.inputmethod.latin.settings.DebugSettings
|
||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
|
||||
import org.dslul.openboard.inputmethod.latin.utils.Log
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
|
@ -54,6 +55,8 @@ Device: ${Build.BRAND} ${Build.DEVICE}, Android ${Build.VERSION.RELEASE}
|
|||
Locale: ${Locale.getDefault()}
|
||||
Stack trace:
|
||||
$stackTrace
|
||||
Last log:
|
||||
${Log.getLog(100).joinToString("\n")}
|
||||
""")
|
||||
defaultUncaughtExceptionHandler!!.uncaughtException(t, e)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ fun loadCustomLayout(uri: Uri?, localeString: String, context: Context, onAdded:
|
|||
fun loadCustomLayout(layoutContent: String, layoutName: String, localeString: String, context: Context, onAdded: (String) -> Unit) {
|
||||
var name = layoutName
|
||||
val isJson = checkLayout(layoutContent, context)
|
||||
?: return infoDialog(context, context.getString(R.string.layout_error, "invalid layout file, ${Log.getLog().lastOrNull { it.tag == TAG }?.message}"))
|
||||
?: return infoDialog(context, context.getString(R.string.layout_error, "invalid layout file, ${Log.getLog(10).lastOrNull { it.tag == TAG }?.message}"))
|
||||
|
||||
AlertDialog.Builder(context)
|
||||
.setTitle(R.string.title_layout_name_select)
|
||||
|
@ -146,7 +146,7 @@ fun editCustomLayout(layoutName: String, context: Context, startContent: String?
|
|||
val isJson = checkLayout(content, context)
|
||||
if (isJson == null) {
|
||||
editCustomLayout(layoutName, context, content)
|
||||
infoDialog(context, context.getString(R.string.layout_error, Log.getLog().lastOrNull { it.tag == TAG }?.message))
|
||||
infoDialog(context, context.getString(R.string.layout_error, Log.getLog(10).lastOrNull { it.tag == TAG }?.message))
|
||||
} else {
|
||||
val wasJson = file.name.substringAfterLast(".") == "json"
|
||||
file.writeText(content)
|
||||
|
|
|
@ -81,7 +81,7 @@ object Log {
|
|||
private val logLines: MutableList<LogLine> = ArrayList(2000)
|
||||
|
||||
/** returns a copy of [logLines] */
|
||||
fun getLog() = synchronized(logLines) { logLines.toList() }
|
||||
fun getLog(maxLines: Int = logLines.size) = synchronized(logLines) { logLines.takeLast(maxLines) }
|
||||
}
|
||||
|
||||
data class LogLine(val level: Char, val tag: String?, val message: String) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue