Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduct params of v4-client calls from logs #107

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.stateIn
import timber.log.Timber
import java.time.Instant
import java.time.temporal.ChronoUnit
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package exchange.dydx.trading.integration.cosmos
import android.app.Application
import exchange.dydx.integration.javascript.JavascriptApiImpl
import exchange.dydx.integration.javascript.JavascriptRunnerV4
import exchange.dydx.trading.common.BuildConfig
import exchange.dydx.trading.common.di.CoroutineScopes
import exchange.dydx.utilities.utils.Logging
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -208,7 +209,9 @@ class CosmosV4ClientWebview @Inject constructor(
function = functionName,
params = jsParams,
) { result ->
logger.d(TAG, "callNativeClient $functionName, params: $params, result: $result")
// for debug builds, log the full params, otherwise redact them
val paramsString = if (BuildConfig.DEBUG) "$params" else "[REDUCTED]"
logger.d(TAG, "callNativeClient $functionName, params: $paramsString, result: $result")
completion(result?.response)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import exchange.dydx.trading.common.AppConfig
import exchange.dydx.trading.common.BuildConfig
import exchange.dydx.utilities.utils.Logging
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -133,7 +134,9 @@ class JavascriptRunnerV4 constructor(
return@launch
}
try {
logger.d(TAG, "Running script: ${script.take(1024)}")
// for production, only log the first 32 characters to avoid logging sensitive data
val length = if (BuildConfig.DEBUG) 1024 else 32
logger.d(TAG, "Running script: ${script.take(length)}")
localWebview.evaluateJavascript(
script,
) {
Expand Down
Loading