Loading core/logging/impl-legacy/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ kotlin { sourceSets { androidMain.dependencies { implementation(libs.timber) implementation(projects.core.logging.implComposite) implementation(projects.core.logging.implFile) } commonMain.dependencies { Loading core/logging/impl-legacy/src/androidMain/kotlin/net/thunderbird/core/logging/legacy/DebugLogConfigurator.kt +16 −3 Original line number Diff line number Diff line package net.thunderbird.core.logging.legacy 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 { class DebugLogConfigurator( private val syncDebugCompositeSink: CompositeLogSink, private val syncDebugFileLogSink: FileLogSink, ) { fun updateLoggingStatus(isDebugLoggingEnabled: Boolean) { Timber.uprootAll() if (isDebugLoggingEnabled) { Timber.plant(Timber.DebugTree()) Timber.plant(DebugTree()) } } fun updateSyncLogging(isSyncLoggingEnabled: Boolean) { if (isSyncLoggingEnabled) { syncDebugCompositeSink.manager.add(syncDebugFileLogSink) } else { syncDebugCompositeSink.manager.remove(syncDebugFileLogSink) } } } core/preference/api/src/commonMain/kotlin/net/thunderbird/core/preference/debugging/DebuggingSettings.kt +2 −0 Original line number Diff line number Diff line package net.thunderbird.core.preference.debugging const val DEBUGGING_SETTINGS_DEFAULT_IS_SYNC_LOGGING_ENABLED = false val DEBUGGING_SETTINGS_DEFAULT_IS_DEBUGGING_LOGGING_ENABLED = isDebug data class DebuggingSettings( val isDebugLoggingEnabled: Boolean = DEBUGGING_SETTINGS_DEFAULT_IS_DEBUGGING_LOGGING_ENABLED, val isSyncLoggingEnabled: Boolean = DEBUGGING_SETTINGS_DEFAULT_IS_SYNC_LOGGING_ENABLED, ) core/preference/api/src/commonMain/kotlin/net/thunderbird/core/preference/debugging/DebuggingSettingsPreferenceManager.kt +1 −0 Original line number Diff line number Diff line Loading @@ -3,5 +3,6 @@ package net.thunderbird.core.preference.debugging import net.thunderbird.core.preference.PreferenceManager const val KEY_ENABLE_DEBUG_LOGGING = "enableDebugLogging" const val KEY_ENABLE_SYNC_DEBUG_LOGGING = "enableSyncDebugLogging" interface DebuggingSettingsPreferenceManager : PreferenceManager<DebuggingSettings> core/preference/impl/src/commonMain/kotlin/net/thunderbird/core/preference/debugging/DefaultDebuggingSettingsPreferenceManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,10 @@ class DefaultDebuggingSettingsPreferenceManager( KEY_ENABLE_DEBUG_LOGGING, DEBUGGING_SETTINGS_DEFAULT_IS_DEBUGGING_LOGGING_ENABLED, ), isSyncLoggingEnabled = storage.getBoolean( KEY_ENABLE_SYNC_DEBUG_LOGGING, DEBUGGING_SETTINGS_DEFAULT_IS_SYNC_LOGGING_ENABLED, ), ) private fun writeConfig(config: DebuggingSettings) { Loading @@ -47,6 +51,7 @@ class DefaultDebuggingSettingsPreferenceManager( scope.launch(ioDispatcher) { mutex.withLock { storageEditor.putBoolean(KEY_ENABLE_DEBUG_LOGGING, config.isDebugLoggingEnabled) storageEditor.putBoolean(KEY_ENABLE_SYNC_DEBUG_LOGGING, config.isSyncLoggingEnabled) storageEditor.commit().also { commited -> logger.verbose(TAG) { "writeConfig: storageEditor.commit() resulted in: $commited" } } Loading Loading
core/logging/impl-legacy/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ kotlin { sourceSets { androidMain.dependencies { implementation(libs.timber) implementation(projects.core.logging.implComposite) implementation(projects.core.logging.implFile) } commonMain.dependencies { Loading
core/logging/impl-legacy/src/androidMain/kotlin/net/thunderbird/core/logging/legacy/DebugLogConfigurator.kt +16 −3 Original line number Diff line number Diff line package net.thunderbird.core.logging.legacy 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 { class DebugLogConfigurator( private val syncDebugCompositeSink: CompositeLogSink, private val syncDebugFileLogSink: FileLogSink, ) { fun updateLoggingStatus(isDebugLoggingEnabled: Boolean) { Timber.uprootAll() if (isDebugLoggingEnabled) { Timber.plant(Timber.DebugTree()) Timber.plant(DebugTree()) } } fun updateSyncLogging(isSyncLoggingEnabled: Boolean) { if (isSyncLoggingEnabled) { syncDebugCompositeSink.manager.add(syncDebugFileLogSink) } else { syncDebugCompositeSink.manager.remove(syncDebugFileLogSink) } } }
core/preference/api/src/commonMain/kotlin/net/thunderbird/core/preference/debugging/DebuggingSettings.kt +2 −0 Original line number Diff line number Diff line package net.thunderbird.core.preference.debugging const val DEBUGGING_SETTINGS_DEFAULT_IS_SYNC_LOGGING_ENABLED = false val DEBUGGING_SETTINGS_DEFAULT_IS_DEBUGGING_LOGGING_ENABLED = isDebug data class DebuggingSettings( val isDebugLoggingEnabled: Boolean = DEBUGGING_SETTINGS_DEFAULT_IS_DEBUGGING_LOGGING_ENABLED, val isSyncLoggingEnabled: Boolean = DEBUGGING_SETTINGS_DEFAULT_IS_SYNC_LOGGING_ENABLED, )
core/preference/api/src/commonMain/kotlin/net/thunderbird/core/preference/debugging/DebuggingSettingsPreferenceManager.kt +1 −0 Original line number Diff line number Diff line Loading @@ -3,5 +3,6 @@ package net.thunderbird.core.preference.debugging import net.thunderbird.core.preference.PreferenceManager const val KEY_ENABLE_DEBUG_LOGGING = "enableDebugLogging" const val KEY_ENABLE_SYNC_DEBUG_LOGGING = "enableSyncDebugLogging" interface DebuggingSettingsPreferenceManager : PreferenceManager<DebuggingSettings>
core/preference/impl/src/commonMain/kotlin/net/thunderbird/core/preference/debugging/DefaultDebuggingSettingsPreferenceManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,10 @@ class DefaultDebuggingSettingsPreferenceManager( KEY_ENABLE_DEBUG_LOGGING, DEBUGGING_SETTINGS_DEFAULT_IS_DEBUGGING_LOGGING_ENABLED, ), isSyncLoggingEnabled = storage.getBoolean( KEY_ENABLE_SYNC_DEBUG_LOGGING, DEBUGGING_SETTINGS_DEFAULT_IS_SYNC_LOGGING_ENABLED, ), ) private fun writeConfig(config: DebuggingSettings) { Loading @@ -47,6 +51,7 @@ class DefaultDebuggingSettingsPreferenceManager( scope.launch(ioDispatcher) { mutex.withLock { storageEditor.putBoolean(KEY_ENABLE_DEBUG_LOGGING, config.isDebugLoggingEnabled) storageEditor.putBoolean(KEY_ENABLE_SYNC_DEBUG_LOGGING, config.isSyncLoggingEnabled) storageEditor.commit().also { commited -> logger.verbose(TAG) { "writeConfig: storageEditor.commit() resulted in: $commited" } } Loading