Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/logging/config/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

Expand Down
1 change: 1 addition & 0 deletions legacy/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading