From cf1d66bc01169410eae217e2582adbd9a34c0fd9 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 30 Jul 2025 16:50:36 -0400 Subject: [PATCH] new parameter to only log when a given amount of ms have passed. --- .../src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt | 5 ++++- .../amethyst/service/okhttp/OkHttpClientFactory.kt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt index 6fd11fd16..eafafe292 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/DebugUtils.kt @@ -152,11 +152,14 @@ fun debugState(context: Context) { inline fun logTime( debugMessage: String, + minToReportMs: Int = 0, block: () -> T, ): T = if (isDebug) { val (result, elapsed) = measureTimedValue(block) - Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage") + if (elapsed.inWholeMilliseconds > minToReportMs) { + Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage") + } result } else { block() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpClientFactory.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpClientFactory.kt index 16918a4a9..bf87bdbcb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpClientFactory.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpClientFactory.kt @@ -30,7 +30,7 @@ class OkHttpClientFactory( keyCache: EncryptionKeyCache, ) { companion object { - // by picking a random proxy port, the connection will fail as it shouold. + // by picking a random proxy port, the connection will fail as it should. const val DEFAULT_SOCKS_PORT: Int = 9050 const val DEFAULT_IS_MOBILE: Boolean = false const val DEFAULT_TIMEOUT_ON_WIFI_SECS: Int = 10