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(
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()

View File

@@ -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