搜索菜品入库改为自动拍照保存,取消手动拍照操作;增加向量数据库相关日志

This commit is contained in:
mazengfei
2026-03-03 15:39:11 +08:00
parent b034e9371f
commit 9a5258ad34
10 changed files with 157 additions and 95 deletions
@@ -29,7 +29,6 @@ class CrashHandler private constructor(private val context: Context) :
companion object {
private const val TAG = "CrashHandler"
private const val CRASH_REPORTS_DIR = "crash_reports"
private const val LOG_LINES = 500 // 收集最近500行日志
@Volatile
@@ -109,7 +108,7 @@ class CrashHandler private constructor(private val context: Context) :
val crashInfo = collectCrashInfo(thread, ex)
// 保存日志文件
saveCrashInfoToFile(crashInfo)
LogSaveUtil.saveLogFile("yyyy-MM-dd_HH-mm-ss",crashInfo)
// 这里可以添加其他处理逻辑,比如上传到服务器等
}
@@ -203,36 +202,11 @@ 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 {
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")
}
}
}
/**
* 清理旧的崩溃日志
*/
fun cleanupOldCrashReports(maxAgeDays: Int = 7) {
val crashDir = getCrashDir()
val crashDir = LogSaveUtil.getCrashDir()
if (!crashDir.exists() || !crashDir.isDirectory) return
val now = System.currentTimeMillis()
@@ -245,17 +219,4 @@ class CrashHandler private constructor(private val context: Context) :
}
}
private fun getCrashDir():File {
//val crashDir = File(context.getExternalFilesDir(null), CRASH_REPORTS_DIR)
var crashDir = File(context.filesDir, CRASH_REPORTS_DIR)
if (!crashDir.exists()) {
crashDir.mkdirs()
}
if (!(crashDir.exists())) {
crashDir = File(context.cacheDir, CRASH_REPORTS_DIR)
}
return crashDir
}
}