logging: make the writer total and harden export

Never let a log-write or export failure reach the uncaught handler: wrap the async writer and crash path, synchronize export with rotation, and tolerate vanished files. Redact the Logcat stack-trace copy, stop leaking rows=0 on writes, shut down the previous writer on re-init, and drop unused API. Strengthen tests for the batched write path, rotation count and throwable redaction.
This commit is contained in:
austinried
2026-10-09 07:58:55 +00:00
parent 7a890094fc
commit 8fe26a36b1
7 changed files with 102 additions and 43 deletions
@@ -6,6 +6,7 @@ import androidx.sqlite.SQLiteConnection
import androidx.sqlite.SQLiteDriver
import androidx.sqlite.SQLiteStatement
import com.subtracks.log.Log
import kotlinx.coroutines.CancellationException
data class SqlExecution(
val sql: String,
@@ -102,6 +103,8 @@ class LoggedMigration(
val start = System.nanoTime()
try {
delegate.migrate(connection)
} catch (cancellation: CancellationException) {
throw cancellation
} catch (failure: Throwable) {
Log.e("sql", "migration $label failed after ${(System.nanoTime() - start) / 1_000_000}ms", failure)
throw failure