This commit is contained in:
mazengfei
2026-01-29 18:52:44 +08:00
parent c76095788c
commit a7bac4321e
10 changed files with 69 additions and 27 deletions
@@ -203,19 +203,28 @@ class CrashHandler private constructor(private val context: Context) :
}
}
private fun saveLog(logInfo:String) {
val time = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.getDefault()).format(Date())
val fileName = "crash_$time.log"
val crashDir = getCrashDir()
val crashFile = File(crashDir, fileName)
FileOutputStream(crashFile).use { it.write(logInfo.toByteArray()) }
Timber.tag(TAG).d("Crash info saved to: ${crashFile.absolutePath}")
}
private fun saveCrashInfoToFile(crashInfo: String) {
try {
val time = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.getDefault()).format(Date())
val fileName = "crash_$time.log"
val crashDir = getCrashDir()
val crashFile = File(crashDir, fileName)
FileOutputStream(crashFile).use { it.write(crashInfo.toByteArray()) }
Timber.tag(TAG).d("Crash info saved to: ${crashFile.absolutePath}")
saveLog(crashInfo)
} catch (e: Exception) {
Timber.tag(TAG).e(e, "Error saving crash info to file")
try {
saveLog("Error saving crash info to file:${e.message}")
} catch (e: Exception) {
Timber.tag(TAG).e(e, "save exception")
}
}
}
@@ -82,7 +82,7 @@ class PhotoCaptureHelper(
}
Timber.e(exception, errorMsg)
onError(errorMsg)
onError("拍照失败")
}
}
)