From 53fe6a662d6824c38cf19f4b8cca7f463e3d14d6 Mon Sep 17 00:00:00 2001 From: Manabu-GT Date: Mon, 18 May 2026 23:48:42 -0600 Subject: [PATCH 1/2] [docs][refactor] update README/CHANGELOG for maxLogcatEntries + refactor LogcatDataSource --- CHANGELOG.md | 1 + README.md | 12 ++++++++++++ .../internal/data/source/LogcatDataSource.kt | 19 +++++++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8cc5e..71b763c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### New Features * **Thermal status row** – Optional thermal-status indicator for the compact overlay, opt-in via `OverlayMode.FullMetrics(showThermal = true)`. Combines `PowerManager.getCurrentThermalStatus()` with `getThermalHeadroom()` per [Google's ADPF guidance](https://developer.android.com/games/optimize/adpf/thermal#device-limitations-of-the-thermal-api) so devices with an incomplete thermal HAL still surface a useful signal. Requires Android 11 (API 30) or above; row stays hidden on older devices. Resolves [#246](https://github.com/Manabu-GT/DebugOverlay-Android/issues/246). +* **Configurable Logcat buffer size** – New `Config.maxLogcatEntries` controls how many entries the built-in Logcat tab retains (default 300). Also bounds `logcat -T N` / `-t N` so it caps OS replay on panel open and on bug-report snapshots. Reassignable at runtime via `DebugOverlay.configure { maxLogcatEntries = … }`. ## Version 2.5.0 *(2026-05-12)* diff --git a/README.md b/README.md index 351c0d0..85efd5a 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,18 @@ DebugOverlay.configure { The row shows the current thermal-throttling level with a color-coded dot. Labels are abbreviated to fit the compact panel — `None` / `Light` / `Mod` / `Sev` / `Crit` / `Emer` / `Shut` — mapping to `PowerManager.THERMAL_STATUS_NONE` / `_LIGHT` / `_MODERATE` / `_SEVERE` / `_CRITICAL` / `_EMERGENCY` / `_SHUTDOWN` respectively. Requires Android 11 (API 30) or above with a working thermal HAL — the row stays hidden on older devices and on API 30+ devices whose HAL doesn't expose `getThermalHeadroom` data. If the HAL later starts reporting, the row appears on the next poll. +### Logcat buffer size + +The built-in Logcat tab keeps the last 300 entries by default. Override via `maxLogcatEntries`: + +```kotlin +DebugOverlay.configure { + maxLogcatEntries = 1000 +} +``` + +The value also bounds the `logcat -T N` / `-t N` calls, so it caps how many lines the OS replays when the panel opens and when a bug report snapshot is captured. + ### Network request tracking ```kotlin diff --git a/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt b/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt index a821b13..6314782 100644 --- a/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt +++ b/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt @@ -39,7 +39,7 @@ import kotlin.time.Duration.Companion.milliseconds internal class LogcatDataSource( scope: CoroutineScope, private val parser: LogcatEntryParser = LogcatEntryParser(), - initialMaxEntries: Int, + @IntRange(from = 1) initialMaxEntries: Int, ) : LogSource, Clearable, Closeable { @@ -93,7 +93,13 @@ internal class LogcatDataSource( * NOTE: The -T flag with a number fetches the last N lines from this app and continue to listens * for new logs (-t option fetches once and exists immediately). */ - val process = Runtime.getRuntime().exec("logcat -v threadtime,printable,epoch -T $maxEntries").also { + val process = ProcessBuilder( + "logcat", + "-v", + "threadtime,printable,epoch", + "-T", + maxEntries.toString() + ).start().also { synchronized(processLock) { currentProcess = it } @@ -167,8 +173,13 @@ internal class LogcatDataSource( private suspend fun captureLogcatOnce(): List = withContext(Dispatchers.IO) { buildList { // -t N = fetch N recent lines and EXIT (vs -T which streams continuously) - val process = Runtime.getRuntime() - .exec("logcat -v threadtime,printable,epoch -t $maxEntries") + val process = ProcessBuilder( + "logcat", + "-v", + "threadtime,printable,epoch", + "-t", + maxEntries.toString() + ).start() try { InputStreamReader(process.inputStream).useLines { lines -> From 0057974ba5c2accc5a96a5bb747764ef8fb7f01b Mon Sep 17 00:00:00 2001 From: Manabu-GT Date: Tue, 19 May 2026 00:01:45 -0600 Subject: [PATCH 2/2] cr fix --- .../debugoverlay/internal/data/source/LogcatDataSource.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt b/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt index 6314782..ca159f7 100644 --- a/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt +++ b/debugoverlay-core/src/main/kotlin/com/ms/square/debugoverlay/internal/data/source/LogcatDataSource.kt @@ -91,7 +91,7 @@ internal class LogcatDataSource( try { /** * NOTE: The -T flag with a number fetches the last N lines from this app and continue to listens - * for new logs (-t option fetches once and exists immediately). + * for new logs (-t option fetches once and exits immediately). */ val process = ProcessBuilder( "logcat",