new parameter to only log when a given amount of ms have passed.

This commit is contained in:
Vitor Pamplona
2025-07-30 16:50:36 -04:00
parent 414e933686
commit cf1d66bc01
2 changed files with 5 additions and 2 deletions

View File

@@ -152,11 +152,14 @@ fun debugState(context: Context) {
inline fun <T> logTime( inline fun <T> logTime(
debugMessage: String, debugMessage: String,
minToReportMs: Int = 0,
block: () -> T, block: () -> T,
): T = ): T =
if (isDebug) { if (isDebug) {
val (result, elapsed) = measureTimedValue(block) val (result, elapsed) = measureTimedValue(block)
if (elapsed.inWholeMilliseconds > minToReportMs) {
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage") Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage")
}
result result
} else { } else {
block() block()

View File

@@ -30,7 +30,7 @@ class OkHttpClientFactory(
keyCache: EncryptionKeyCache, keyCache: EncryptionKeyCache,
) { ) {
companion object { 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_SOCKS_PORT: Int = 9050
const val DEFAULT_IS_MOBILE: Boolean = false const val DEFAULT_IS_MOBILE: Boolean = false
const val DEFAULT_TIMEOUT_ON_WIFI_SECS: Int = 10 const val DEFAULT_TIMEOUT_ON_WIFI_SECS: Int = 10