From a448b417f746c4ef15d8d6b94278ff6cf28f4b9b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 8 Jul 2025 11:10:45 +0200 Subject: [PATCH] Ensure big log does not crash the application --- .../libraries/network/interceptors/FormattedJsonHttpLogger.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/network/src/main/kotlin/io/element/android/libraries/network/interceptors/FormattedJsonHttpLogger.kt b/libraries/network/src/main/kotlin/io/element/android/libraries/network/interceptors/FormattedJsonHttpLogger.kt index 936662fb54..e2fad575f4 100644 --- a/libraries/network/src/main/kotlin/io/element/android/libraries/network/interceptors/FormattedJsonHttpLogger.kt +++ b/libraries/network/src/main/kotlin/io/element/android/libraries/network/interceptors/FormattedJsonHttpLogger.kt @@ -7,6 +7,7 @@ package io.element.android.libraries.network.interceptors +import io.element.android.libraries.core.extensions.ellipsize import okhttp3.logging.HttpLoggingInterceptor import org.json.JSONArray import org.json.JSONException @@ -28,7 +29,7 @@ internal class FormattedJsonHttpLogger( */ @Synchronized override fun log(message: String) { - Timber.v(message) + Timber.v(message.ellipsize(200_000)) // Try to log formatted Json only if there is a chance that [message] contains Json. // It can be only the case if we log the bodies of Http requests.