Enable Rust trace log packs (#4514)
* Enable Rust trace log packs This is a way to forcefully enable trace logs only for a few Rust crates in a safe way
This commit is contained in:
parent
b2791d5aad
commit
c3ff9c9bda
14 changed files with 131 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ import io.element.android.libraries.core.meta.BuildType
|
|||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.matrix.api.tracing.LogLevel
|
||||
import io.element.android.libraries.matrix.api.tracing.TraceLogPack
|
||||
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
|
@ -32,6 +33,7 @@ private val customElementCallBaseUrlKey = stringPreferencesKey("elementCallBaseU
|
|||
private val themeKey = stringPreferencesKey("theme")
|
||||
private val hideImagesAndVideosKey = booleanPreferencesKey("hideImagesAndVideos")
|
||||
private val logLevelKey = stringPreferencesKey("logLevel")
|
||||
private val traceLogPacksKey = stringPreferencesKey("traceLogPacks")
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultAppPreferencesStore @Inject constructor(
|
||||
|
|
@ -105,6 +107,23 @@ class DefaultAppPreferencesStore @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun setTracingLogPacks(targets: Set<TraceLogPack>) {
|
||||
val value = targets.joinToString(",") { it.key }
|
||||
store.edit { prefs ->
|
||||
prefs[traceLogPacksKey] = value
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTracingLogPacksFlow(): Flow<Set<TraceLogPack>> {
|
||||
return store.data.map { prefs ->
|
||||
prefs[traceLogPacksKey]
|
||||
?.split(",")
|
||||
?.mapNotNull { value -> TraceLogPack.entries.find { it.key == value } }
|
||||
?.toSet()
|
||||
?: emptySet()
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun reset() {
|
||||
store.edit { it.clear() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue