diff --git a/core/logging/config/build.gradle.kts b/core/logging/config/build.gradle.kts new file mode 100644 index 00000000000..a73c997a1ee --- /dev/null +++ b/core/logging/config/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id(ThunderbirdPlugins.Library.kmp) +} + +android { + namespace = "net.thunderbird.core.logging.config" +} + +kotlin { + sourceSets { + commonMain.dependencies { + api(projects.core.logging.api) + implementation(projects.core.logging.implComposite) + implementation(projects.core.logging.implFile) + } + } +} diff --git a/core/logging/impl-legacy/src/androidMain/kotlin/net/thunderbird/core/logging/legacy/DebugLogConfigurator.kt b/core/logging/config/src/commonMain/kotlin/net/thunderbird/core/logging/config/DebugLogConfigurator.kt similarity index 71% rename from core/logging/impl-legacy/src/androidMain/kotlin/net/thunderbird/core/logging/legacy/DebugLogConfigurator.kt rename to core/logging/config/src/commonMain/kotlin/net/thunderbird/core/logging/config/DebugLogConfigurator.kt index 2e8c63df314..2fb6c5d9903 100644 --- a/core/logging/impl-legacy/src/androidMain/kotlin/net/thunderbird/core/logging/legacy/DebugLogConfigurator.kt +++ b/core/logging/config/src/commonMain/kotlin/net/thunderbird/core/logging/config/DebugLogConfigurator.kt @@ -1,19 +1,17 @@ -package net.thunderbird.core.logging.legacy +package net.thunderbird.core.logging.config import net.thunderbird.core.logging.composite.CompositeLogSink import net.thunderbird.core.logging.file.FileLogSink -import timber.log.Timber -import timber.log.Timber.DebugTree -// TODO: Implementation https://github.com/thunderbird/thunderbird-android/issues/9573 class DebugLogConfigurator( private val syncDebugCompositeSink: CompositeLogSink, private val syncDebugFileLogSink: FileLogSink, ) { fun updateLoggingStatus(isDebugLoggingEnabled: Boolean) { - Timber.uprootAll() + syncDebugCompositeSink.manager.removeAll() if (isDebugLoggingEnabled) { - Timber.plant(DebugTree()) + syncDebugCompositeSink.manager.add(syncDebugCompositeSink) + syncDebugCompositeSink.manager.add(syncDebugFileLogSink) } } diff --git a/legacy/core/build.gradle.kts b/legacy/core/build.gradle.kts index a9d4f9f1cd8..94f3e6ee3c2 100644 --- a/legacy/core/build.gradle.kts +++ b/legacy/core/build.gradle.kts @@ -13,6 +13,7 @@ dependencies { api(projects.core.preference.impl) api(projects.core.android.logging) api(projects.core.logging.implFile) + api(projects.core.logging.config) api(projects.core.logging.implComposite) api(projects.core.android.network) api(projects.core.outcome) diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/DefaultGeneralSettingsManager.kt b/legacy/core/src/main/java/com/fsck/k9/preferences/DefaultGeneralSettingsManager.kt index c8a20f61eea..a8fc6c6791d 100644 --- a/legacy/core/src/main/java/com/fsck/k9/preferences/DefaultGeneralSettingsManager.kt +++ b/legacy/core/src/main/java/com/fsck/k9/preferences/DefaultGeneralSettingsManager.kt @@ -13,7 +13,7 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import net.thunderbird.core.logging.legacy.DebugLogConfigurator +import net.thunderbird.core.logging.config.DebugLogConfigurator import net.thunderbird.core.preference.GeneralSettings import net.thunderbird.core.preference.GeneralSettingsManager import net.thunderbird.core.preference.PreferenceChangePublisher diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/KoinModule.kt b/legacy/core/src/main/java/com/fsck/k9/preferences/KoinModule.kt index d9662b4fd17..c34de9df94a 100644 --- a/legacy/core/src/main/java/com/fsck/k9/preferences/KoinModule.kt +++ b/legacy/core/src/main/java/com/fsck/k9/preferences/KoinModule.kt @@ -3,7 +3,7 @@ package com.fsck.k9.preferences import com.fsck.k9.Preferences import kotlin.time.ExperimentalTime import net.thunderbird.core.android.account.LegacyAccountDtoManager -import net.thunderbird.core.logging.legacy.DebugLogConfigurator +import net.thunderbird.core.logging.config.DebugLogConfigurator import net.thunderbird.core.preference.DefaultPreferenceChangeBroker import net.thunderbird.core.preference.GeneralSettingsManager import net.thunderbird.core.preference.PreferenceChangeBroker diff --git a/quality/konsist/src/test/kotlin/net/thunderbird/quality/ValidateLogger.kt b/quality/konsist/src/test/kotlin/net/thunderbird/quality/ValidateLogger.kt index 9e152bd05ef..8b36893f985 100644 --- a/quality/konsist/src/test/kotlin/net/thunderbird/quality/ValidateLogger.kt +++ b/quality/konsist/src/test/kotlin/net/thunderbird/quality/ValidateLogger.kt @@ -30,7 +30,7 @@ class ValidateLogger { .filterNot { it.hasNameMatching("ConsoleLogSink.android|ConsoleLogSinkTest.android".toRegex()) } .filterNot { // Exclude legacy code that still uses Timber - it.hasNameMatching("LogFileWriter|FileLoggerTree|K9|DebugLogConfigurator".toRegex()) + it.hasNameMatching("LogFileWriter|FileLoggerTree|K9".toRegex()) } .assertFalse( additionalMessage = "No class should use timber.log.Timber import, use net.thunderbird.core.logging.Logger instead." diff --git a/settings.gradle.kts b/settings.gradle.kts index 35fb8a7bd7c..f68ddd3cc85 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -153,6 +153,7 @@ include( ":core:configstore:impl-backend", ":core:featureflag", ":core:logging:api", + ":core:logging:config", ":core:logging:impl-composite", ":core:logging:impl-console", ":core:logging:impl-legacy",