Merge pull request #1268 from vector-im/feature/bma/moreTrace
Add SDK trace item, set RUST_BACKTRACE and be able to configure trace before a session exists.
This commit is contained in:
commit
0a8e6ad073
15 changed files with 148 additions and 18 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
package io.element.android.x.initializer
|
package io.element.android.x.initializer
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.system.Os
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.startup.Initializer
|
import androidx.startup.Initializer
|
||||||
import io.element.android.features.preferences.impl.developer.tracing.SharedPrefTracingConfigurationStore
|
import io.element.android.features.preferences.impl.developer.tracing.SharedPrefTracingConfigurationStore
|
||||||
|
|
@ -57,6 +58,8 @@ class TracingInitializer : Initializer<Unit> {
|
||||||
}
|
}
|
||||||
bugReporter.cleanLogDirectoryIfNeeded()
|
bugReporter.cleanLogDirectoryIfNeeded()
|
||||||
tracingService.setupTracing(tracingConfiguration)
|
tracingService.setupTracing(tracingConfiguration)
|
||||||
|
// Also set env variable for rust back trace
|
||||||
|
Os.setenv("RUST_BACKTRACE", "1", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dependencies(): List<Class<out Initializer<*>>> = mutableListOf()
|
override fun dependencies(): List<Class<out Initializer<*>>> = mutableListOf()
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import dagger.assisted.AssistedInject
|
||||||
import io.element.android.anvilannotations.ContributesNode
|
import io.element.android.anvilannotations.ContributesNode
|
||||||
import io.element.android.features.login.api.LoginEntryPoint
|
import io.element.android.features.login.api.LoginEntryPoint
|
||||||
import io.element.android.features.onboarding.api.OnBoardingEntryPoint
|
import io.element.android.features.onboarding.api.OnBoardingEntryPoint
|
||||||
|
import io.element.android.features.preferences.api.ConfigureTracingEntryPoint
|
||||||
import io.element.android.libraries.architecture.BackstackNode
|
import io.element.android.libraries.architecture.BackstackNode
|
||||||
import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
|
import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
|
|
@ -43,6 +44,7 @@ class NotLoggedInFlowNode @AssistedInject constructor(
|
||||||
@Assisted buildContext: BuildContext,
|
@Assisted buildContext: BuildContext,
|
||||||
@Assisted plugins: List<Plugin>,
|
@Assisted plugins: List<Plugin>,
|
||||||
private val onBoardingEntryPoint: OnBoardingEntryPoint,
|
private val onBoardingEntryPoint: OnBoardingEntryPoint,
|
||||||
|
private val configureTracingEntryPoint: ConfigureTracingEntryPoint,
|
||||||
private val loginEntryPoint: LoginEntryPoint,
|
private val loginEntryPoint: LoginEntryPoint,
|
||||||
private val notLoggedInImageLoaderFactory: NotLoggedInImageLoaderFactory,
|
private val notLoggedInImageLoaderFactory: NotLoggedInImageLoaderFactory,
|
||||||
) : BackstackNode<NotLoggedInFlowNode.NavTarget>(
|
) : BackstackNode<NotLoggedInFlowNode.NavTarget>(
|
||||||
|
|
@ -70,6 +72,9 @@ class NotLoggedInFlowNode @AssistedInject constructor(
|
||||||
data class LoginFlow(
|
data class LoginFlow(
|
||||||
val isAccountCreation: Boolean,
|
val isAccountCreation: Boolean,
|
||||||
) : NavTarget
|
) : NavTarget
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data object ConfigureTracing : NavTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
||||||
|
|
@ -83,6 +88,10 @@ class NotLoggedInFlowNode @AssistedInject constructor(
|
||||||
override fun onSignIn() {
|
override fun onSignIn() {
|
||||||
backstack.push(NavTarget.LoginFlow(isAccountCreation = false))
|
backstack.push(NavTarget.LoginFlow(isAccountCreation = false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onOpenDeveloperSettings() {
|
||||||
|
backstack.push(NavTarget.ConfigureTracing)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onBoardingEntryPoint
|
onBoardingEntryPoint
|
||||||
.nodeBuilder(this, buildContext)
|
.nodeBuilder(this, buildContext)
|
||||||
|
|
@ -94,6 +103,9 @@ class NotLoggedInFlowNode @AssistedInject constructor(
|
||||||
.params(LoginEntryPoint.Params(isAccountCreation = navTarget.isAccountCreation))
|
.params(LoginEntryPoint.Params(isAccountCreation = navTarget.isAccountCreation))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
NavTarget.ConfigureTracing -> {
|
||||||
|
configureTracingEntryPoint.createNode(this, buildContext)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,5 +33,6 @@ interface OnBoardingEntryPoint : FeatureEntryPoint {
|
||||||
interface Callback : Plugin {
|
interface Callback : Plugin {
|
||||||
fun onSignUp()
|
fun onSignUp()
|
||||||
fun onSignIn()
|
fun onSignIn()
|
||||||
|
fun onOpenDeveloperSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,10 @@ class OnBoardingNode @AssistedInject constructor(
|
||||||
plugins<OnBoardingEntryPoint.Callback>().forEach { it.onSignUp() }
|
plugins<OnBoardingEntryPoint.Callback>().forEach { it.onSignUp() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onOpenDeveloperSettings() {
|
||||||
|
plugins<OnBoardingEntryPoint.Callback>().forEach { it.onOpenDeveloperSettings() }
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun View(modifier: Modifier) {
|
override fun View(modifier: Modifier) {
|
||||||
val state = presenter.present()
|
val state = presenter.present()
|
||||||
|
|
@ -54,6 +58,8 @@ class OnBoardingNode @AssistedInject constructor(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onSignIn = ::onSignIn,
|
onSignIn = ::onSignIn,
|
||||||
onCreateAccount = ::onSignUp,
|
onCreateAccount = ::onSignUp,
|
||||||
|
onSignInWithQrCode = { /* Not supported yet */ },
|
||||||
|
onOpenDeveloperSettings = ::onOpenDeveloperSettings,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ package io.element.android.features.onboarding.impl
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
|
import io.element.android.libraries.core.meta.BuildMeta
|
||||||
|
import io.element.android.libraries.core.meta.BuildType
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,10 +27,12 @@ import javax.inject.Inject
|
||||||
* When this presenter get more code in it, please remove the ignore rule in the kover configuration.
|
* When this presenter get more code in it, please remove the ignore rule in the kover configuration.
|
||||||
*/
|
*/
|
||||||
class OnBoardingPresenter @Inject constructor(
|
class OnBoardingPresenter @Inject constructor(
|
||||||
|
private val buildMeta: BuildMeta,
|
||||||
) : Presenter<OnBoardingState> {
|
) : Presenter<OnBoardingState> {
|
||||||
@Composable
|
@Composable
|
||||||
override fun present(): OnBoardingState {
|
override fun present(): OnBoardingState {
|
||||||
return OnBoardingState(
|
return OnBoardingState(
|
||||||
|
isDebugBuild = buildMeta.buildType != BuildType.RELEASE,
|
||||||
canLoginWithQrCode = OnBoardingConfig.canLoginWithQrCode,
|
canLoginWithQrCode = OnBoardingConfig.canLoginWithQrCode,
|
||||||
canCreateAccount = OnBoardingConfig.canCreateAccount,
|
canCreateAccount = OnBoardingConfig.canCreateAccount,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package io.element.android.features.onboarding.impl
|
package io.element.android.features.onboarding.impl
|
||||||
|
|
||||||
data class OnBoardingState(
|
data class OnBoardingState(
|
||||||
|
val isDebugBuild: Boolean,
|
||||||
val canLoginWithQrCode: Boolean,
|
val canLoginWithQrCode: Boolean,
|
||||||
val canCreateAccount: Boolean,
|
val canCreateAccount: Boolean,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,16 @@ open class OnBoardingStateProvider : PreviewParameterProvider<OnBoardingState> {
|
||||||
anOnBoardingState(canLoginWithQrCode = true),
|
anOnBoardingState(canLoginWithQrCode = true),
|
||||||
anOnBoardingState(canCreateAccount = true),
|
anOnBoardingState(canCreateAccount = true),
|
||||||
anOnBoardingState(canLoginWithQrCode = true, canCreateAccount = true),
|
anOnBoardingState(canLoginWithQrCode = true, canCreateAccount = true),
|
||||||
|
anOnBoardingState(isDebugBuild = true),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun anOnBoardingState(
|
fun anOnBoardingState(
|
||||||
|
isDebugBuild: Boolean = false,
|
||||||
canLoginWithQrCode: Boolean = false,
|
canLoginWithQrCode: Boolean = false,
|
||||||
canCreateAccount: Boolean = false
|
canCreateAccount: Boolean = false
|
||||||
) = OnBoardingState(
|
) = OnBoardingState(
|
||||||
|
isDebugBuild = isDebugBuild,
|
||||||
canLoginWithQrCode = canLoginWithQrCode,
|
canLoginWithQrCode = canLoginWithQrCode,
|
||||||
canCreateAccount = canCreateAccount
|
canCreateAccount = canCreateAccount
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,9 @@ import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.QrCode
|
import androidx.compose.material.icons.filled.QrCode
|
||||||
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
|
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
|
||||||
import androidx.compose.ui.BiasAlignment
|
import androidx.compose.ui.BiasAlignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
@ -41,6 +43,8 @@ import io.element.android.libraries.designsystem.atomic.pages.OnBoardingPage
|
||||||
import io.element.android.libraries.designsystem.preview.DayNightPreviews
|
import io.element.android.libraries.designsystem.preview.DayNightPreviews
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.theme.components.Button
|
import io.element.android.libraries.designsystem.theme.components.Button
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.IconButton
|
||||||
import io.element.android.libraries.designsystem.theme.components.IconSource
|
import io.element.android.libraries.designsystem.theme.components.IconSource
|
||||||
import io.element.android.libraries.designsystem.theme.components.OutlinedButton
|
import io.element.android.libraries.designsystem.theme.components.OutlinedButton
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
|
|
@ -57,15 +61,19 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
@Composable
|
@Composable
|
||||||
fun OnBoardingView(
|
fun OnBoardingView(
|
||||||
state: OnBoardingState,
|
state: OnBoardingState,
|
||||||
|
onSignInWithQrCode: () -> Unit,
|
||||||
|
onSignIn: () -> Unit,
|
||||||
|
onCreateAccount: () -> Unit,
|
||||||
|
onOpenDeveloperSettings: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onSignInWithQrCode: () -> Unit = {},
|
|
||||||
onSignIn: () -> Unit = {},
|
|
||||||
onCreateAccount: () -> Unit = {},
|
|
||||||
) {
|
) {
|
||||||
OnBoardingPage(
|
OnBoardingPage(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
content = {
|
content = {
|
||||||
OnBoardingContent()
|
OnBoardingContent(
|
||||||
|
state = state,
|
||||||
|
onOpenDeveloperSettings = onOpenDeveloperSettings
|
||||||
|
)
|
||||||
},
|
},
|
||||||
footer = {
|
footer = {
|
||||||
OnBoardingButtons(
|
OnBoardingButtons(
|
||||||
|
|
@ -79,7 +87,11 @@ fun OnBoardingView(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun OnBoardingContent(modifier: Modifier = Modifier) {
|
private fun OnBoardingContent(
|
||||||
|
state: OnBoardingState,
|
||||||
|
onOpenDeveloperSettings: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier.fillMaxSize(),
|
modifier = modifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
|
|
@ -122,6 +134,17 @@ private fun OnBoardingContent(modifier: Modifier = Modifier) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (state.isDebugBuild) {
|
||||||
|
IconButton(
|
||||||
|
modifier = Modifier.align(Alignment.TopEnd),
|
||||||
|
onClick = onOpenDeveloperSettings,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Filled.Settings,
|
||||||
|
contentDescription = stringResource(CommonStrings.common_settings)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,5 +195,11 @@ private fun OnBoardingButtons(
|
||||||
internal fun OnBoardingScreenPreview(
|
internal fun OnBoardingScreenPreview(
|
||||||
@PreviewParameter(OnBoardingStateProvider::class) state: OnBoardingState
|
@PreviewParameter(OnBoardingStateProvider::class) state: OnBoardingState
|
||||||
) = ElementPreview {
|
) = ElementPreview {
|
||||||
OnBoardingView(state)
|
OnBoardingView(
|
||||||
|
state = state,
|
||||||
|
onSignInWithQrCode = {},
|
||||||
|
onSignIn = {},
|
||||||
|
onCreateAccount = {},
|
||||||
|
onOpenDeveloperSettings = {}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import app.cash.molecule.RecompositionMode
|
||||||
import app.cash.molecule.moleculeFlow
|
import app.cash.molecule.moleculeFlow
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.libraries.core.meta.BuildType
|
||||||
|
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||||
import io.element.android.tests.testutils.WarmUpRule
|
import io.element.android.tests.testutils.WarmUpRule
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
|
|
@ -33,13 +35,25 @@ class OnBoardingPresenterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - initial state`() = runTest {
|
fun `present - initial state`() = runTest {
|
||||||
val presenter = OnBoardingPresenter()
|
val presenter = OnBoardingPresenter(aBuildMeta())
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
presenter.present()
|
presenter.present()
|
||||||
}.test {
|
}.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
|
assertThat(initialState.isDebugBuild).isTrue()
|
||||||
assertThat(initialState.canLoginWithQrCode).isFalse()
|
assertThat(initialState.canLoginWithQrCode).isFalse()
|
||||||
assertThat(initialState.canCreateAccount).isFalse()
|
assertThat(initialState.canCreateAccount).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - initial state release`() = runTest {
|
||||||
|
val presenter = OnBoardingPresenter(aBuildMeta(buildType = BuildType.RELEASE))
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
presenter.present()
|
||||||
|
}.test {
|
||||||
|
val initialState = awaitItem()
|
||||||
|
assertThat(initialState.isDebugBuild).isFalse()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.preferences.api
|
||||||
|
|
||||||
|
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
|
||||||
|
|
||||||
|
interface ConfigureTracingEntryPoint : SimpleFeatureEntryPoint
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.preferences.impl
|
||||||
|
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.core.node.Node
|
||||||
|
import com.squareup.anvil.annotations.ContributesBinding
|
||||||
|
import io.element.android.features.preferences.api.ConfigureTracingEntryPoint
|
||||||
|
import io.element.android.features.preferences.impl.developer.tracing.ConfigureTracingNode
|
||||||
|
import io.element.android.libraries.architecture.createNode
|
||||||
|
import io.element.android.libraries.di.AppScope
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ContributesBinding(AppScope::class)
|
||||||
|
class DefaultConfigureTracingEntryPoint @Inject constructor() : ConfigureTracingEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext): Node {
|
||||||
|
return parentNode.createNode<ConfigureTracingNode>(buildContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -29,7 +29,6 @@ class TargetLogLevelMapBuilder @Inject constructor(
|
||||||
fun getDefaultMap(): Map<Target, LogLevel> {
|
fun getDefaultMap(): Map<Target, LogLevel> {
|
||||||
return Target.entries.associateWith { target ->
|
return Target.entries.associateWith { target ->
|
||||||
defaultConfig.getLogLevel(target)
|
defaultConfig.getLogLevel(target)
|
||||||
?: LogLevel.INFO
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,7 +36,6 @@ class TargetLogLevelMapBuilder @Inject constructor(
|
||||||
return Target.entries.associateWith { target ->
|
return Target.entries.associateWith { target ->
|
||||||
tracingConfigurationStore.getLogLevel(target)
|
tracingConfigurationStore.getLogLevel(target)
|
||||||
?: defaultConfig.getLogLevel(target)
|
?: defaultConfig.getLogLevel(target)
|
||||||
?: LogLevel.INFO
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,27 +19,25 @@ package io.element.android.libraries.matrix.api.tracing
|
||||||
data class TracingFilterConfiguration(
|
data class TracingFilterConfiguration(
|
||||||
val overrides: Map<Target, LogLevel> = emptyMap(),
|
val overrides: Map<Target, LogLevel> = emptyMap(),
|
||||||
) {
|
) {
|
||||||
|
private val defaultLogLevel = LogLevel.INFO
|
||||||
|
|
||||||
// Order should matters
|
// Order should matters
|
||||||
private val targetsToLogLevel: Map<Target, LogLevel> = mapOf(
|
private val targetsToLogLevel: Map<Target, LogLevel> = mapOf(
|
||||||
Target.COMMON to LogLevel.INFO,
|
|
||||||
Target.HYPER to LogLevel.WARN,
|
Target.HYPER to LogLevel.WARN,
|
||||||
Target.MATRIX_SDK_CRYPTO to LogLevel.DEBUG,
|
Target.MATRIX_SDK_CRYPTO to LogLevel.DEBUG,
|
||||||
Target.MATRIX_SDK_HTTP_CLIENT to LogLevel.DEBUG,
|
Target.MATRIX_SDK_HTTP_CLIENT to LogLevel.DEBUG,
|
||||||
Target.MATRIX_SDK_SLIDING_SYNC to LogLevel.TRACE,
|
Target.MATRIX_SDK_SLIDING_SYNC to LogLevel.TRACE,
|
||||||
Target.MATRIX_SDK_BASE_SLIDING_SYNC to LogLevel.TRACE,
|
Target.MATRIX_SDK_BASE_SLIDING_SYNC to LogLevel.TRACE,
|
||||||
Target.MATRIX_SDK_UI_TIMELINE to LogLevel.INFO,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getLogLevel(target: Target): LogLevel? {
|
fun getLogLevel(target: Target): LogLevel {
|
||||||
return overrides[target] ?: targetsToLogLevel[target]
|
return overrides[target] ?: targetsToLogLevel[target] ?: defaultLogLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
val filter: String
|
val filter: String
|
||||||
get() {
|
get() {
|
||||||
val fullMap = targetsToLogLevel.toMutableMap()
|
val fullMap = Target.values().associateWith {
|
||||||
overrides.forEach { (target, logLevel) ->
|
overrides[it] ?: targetsToLogLevel[it] ?: defaultLogLevel
|
||||||
fullMap[target] = logLevel
|
|
||||||
}
|
}
|
||||||
return fullMap.map {
|
return fullMap.map {
|
||||||
if (it.key.filter.isEmpty()) {
|
if (it.key.filter.isEmpty()) {
|
||||||
|
|
@ -58,7 +56,10 @@ enum class Target(open val filter: String) {
|
||||||
MATRIX_SDK_FFI("matrix_sdk_ffi"),
|
MATRIX_SDK_FFI("matrix_sdk_ffi"),
|
||||||
MATRIX_SDK_UNIFFI_API("matrix_sdk_ffi::uniffi_api"),
|
MATRIX_SDK_UNIFFI_API("matrix_sdk_ffi::uniffi_api"),
|
||||||
MATRIX_SDK_CRYPTO("matrix_sdk_crypto"),
|
MATRIX_SDK_CRYPTO("matrix_sdk_crypto"),
|
||||||
|
MATRIX_SDK("matrix_sdk"),
|
||||||
MATRIX_SDK_HTTP_CLIENT("matrix_sdk::http_client"),
|
MATRIX_SDK_HTTP_CLIENT("matrix_sdk::http_client"),
|
||||||
|
MATRIX_SDK_CLIENT("matrix_sdk::client"),
|
||||||
|
MATRIX_SDK_OIDC("matrix_sdk::oidc"),
|
||||||
MATRIX_SDK_SLIDING_SYNC("matrix_sdk::sliding_sync"),
|
MATRIX_SDK_SLIDING_SYNC("matrix_sdk::sliding_sync"),
|
||||||
MATRIX_SDK_BASE_SLIDING_SYNC("matrix_sdk_base::sliding_sync"),
|
MATRIX_SDK_BASE_SLIDING_SYNC("matrix_sdk_base::sliding_sync"),
|
||||||
MATRIX_SDK_UI_TIMELINE("matrix_sdk_ui::timeline"),
|
MATRIX_SDK_UI_TIMELINE("matrix_sdk_ui::timeline"),
|
||||||
|
|
@ -75,13 +76,11 @@ enum class LogLevel(open val filter: String) {
|
||||||
object TracingFilterConfigurations {
|
object TracingFilterConfigurations {
|
||||||
val release = TracingFilterConfiguration(
|
val release = TracingFilterConfiguration(
|
||||||
overrides = mapOf(
|
overrides = mapOf(
|
||||||
Target.COMMON to LogLevel.INFO,
|
|
||||||
Target.ELEMENT to LogLevel.DEBUG
|
Target.ELEMENT to LogLevel.DEBUG
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
val debug = TracingFilterConfiguration(
|
val debug = TracingFilterConfiguration(
|
||||||
overrides = mapOf(
|
overrides = mapOf(
|
||||||
Target.COMMON to LogLevel.INFO,
|
|
||||||
Target.ELEMENT to LogLevel.TRACE
|
Target.ELEMENT to LogLevel.TRACE
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:c2c67243e8def6f8d188eb918b0dbd57dec3aae03fe8fca90ef5529658de537b
|
||||||
|
size 327304
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:84e5641cce0113690d0d626bd3b17e8945728b3835a06b06a645418d12a05022
|
||||||
|
size 421112
|
||||||
Loading…
Add table
Add a link
Reference in a new issue