From d50df9537cc6f7d8a698087862a4f5e6a1d39223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 16 Feb 2021 11:26:24 +0100 Subject: [PATCH] crypto: Connect the rust logger to timber --- .../sdk/internal/crypto/DefaultCryptoService.kt | 2 ++ .../org/matrix/android/sdk/internal/newCrypto.kt | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index ac51e1dca0..de73e04f12 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -57,6 +57,7 @@ import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibilityConten import org.matrix.android.sdk.api.session.room.model.RoomMemberContent import org.matrix.android.sdk.api.util.JsonDict import org.matrix.android.sdk.internal.OlmMachine +import org.matrix.android.sdk.internal.setRustLogger import org.matrix.android.sdk.internal.crypto.actions.MegolmSessionDataImporter import org.matrix.android.sdk.internal.crypto.actions.SetDeviceVerificationAction import org.matrix.android.sdk.internal.crypto.algorithms.IMXEncrypting @@ -375,6 +376,7 @@ internal class DefaultCryptoService @Inject constructor( Timber.v("HELLLO WORLD STARTING CRYPTO") try { + setRustLogger() olmMachine = OlmMachine(userId, deviceId!!, dataDir) Timber.v("HELLLO WORLD STARTING $dataDir CRYPTO ${olmMachine?.identityKeys()}") diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt index 22da46ee33..20bde0ca1d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/newCrypto.kt @@ -24,6 +24,20 @@ import uniffi.olm.OlmMachine as InnerMachine import uniffi.olm.Request import uniffi.olm.RequestType import uniffi.olm.Sas as InnerSas +import uniffi.olm.Logger +import uniffi.olm.setLogger + +import timber.log.Timber + +class CryptoLogger(): Logger { + override fun log(logLine: String) { + Timber.d(logLine) + } +} + +fun setRustLogger() { + setLogger(CryptoLogger() as Logger) +} class Device(inner: InnerDevice, machine: InnerMachine) { private val machine: InnerMachine = machine