From c5f5c7ca8bbf69ebf181ba015e08ea0312cdf20b Mon Sep 17 00:00:00 2001 From: John O'Reilly Date: Thu, 9 Dec 2021 21:30:59 +0000 Subject: [PATCH] Kermit 1.0 --- .../com/surrus/peopleinspace/PeopleInSpaceApplication.kt | 8 ++------ .../com/surrus/peopleinspace/ui/PeopleInSpaceViewModel.kt | 2 -- buildSrc/src/main/java/Dependencies.kt | 2 +- .../kotlin/com/surrus/common/repository/actual.kt | 2 -- common/src/commonMain/kotlin/com/surrus/common/di/Koin.kt | 2 -- .../surrus/common/repository/PeopleInSpaceRepository.kt | 8 ++++---- .../iOSMain/kotlin/com/surrus/common/repository/actual.kt | 3 --- .../jsMain/kotlin/com/surrus/common/repository/actual.kt | 4 ---- .../jvmMain/kotlin/com/surrus/common/repository/actual.kt | 4 ---- .../kotlin/com/surrus/common/repository/actual.kt | 3 --- .../kotlin/com/surrus/common/repository/actual.kt | 3 --- .../com/surrus/peopleinspace/PeopleInSpaceApplication.kt | 5 ++--- .../com/surrus/peopleinspace/PeopleInSpaceViewModel.kt | 2 -- web/src/main/kotlin/Main.kt | 3 --- 14 files changed, 9 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt b/app/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt index 409e385..3930c13 100644 --- a/app/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt +++ b/app/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt @@ -1,20 +1,16 @@ package com.surrus.peopleinspace import android.app.Application -import co.touchlab.kermit.Kermit +import co.touchlab.kermit.Logger import com.surrus.common.di.initKoin import com.surrus.peopleinspace.di.appModule -import org.koin.android.ext.android.inject import org.koin.android.ext.koin.androidContext import org.koin.android.ext.koin.androidLogger -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject import org.koin.core.logger.Level import org.osmdroid.config.Configuration import java.io.File class PeopleInSpaceApplication : Application() { - private val logger: Kermit by inject() override fun onCreate() { super.onCreate() @@ -32,6 +28,6 @@ class PeopleInSpaceApplication : Application() { modules(appModule) } - logger.d { "PeopleInSpaceApplication" } + Logger.d { "PeopleInSpaceApplication" } } } diff --git a/app/src/main/java/com/surrus/peopleinspace/ui/PeopleInSpaceViewModel.kt b/app/src/main/java/com/surrus/peopleinspace/ui/PeopleInSpaceViewModel.kt index ef6c537..e86123c 100644 --- a/app/src/main/java/com/surrus/peopleinspace/ui/PeopleInSpaceViewModel.kt +++ b/app/src/main/java/com/surrus/peopleinspace/ui/PeopleInSpaceViewModel.kt @@ -2,9 +2,7 @@ package com.surrus.peopleinspace.ui import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import co.touchlab.kermit.Kermit import com.surrus.common.remote.Assignment -import com.surrus.common.repository.PeopleInSpaceRepository import com.surrus.common.repository.PeopleInSpaceRepositoryInterface import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.stateIn diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index ce2fee7..385b4f2 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -38,7 +38,7 @@ object Versions { const val slf4j = "1.7.30" const val logback = "1.2.3" - const val kermit = "0.1.9" + const val kermit = "1.0.0" const val gradleVersionsPlugin = "0.39.0" } diff --git a/common/src/androidMain/kotlin/com/surrus/common/repository/actual.kt b/common/src/androidMain/kotlin/com/surrus/common/repository/actual.kt index e2bfd5e..bd4b349 100644 --- a/common/src/androidMain/kotlin/com/surrus/common/repository/actual.kt +++ b/common/src/androidMain/kotlin/com/surrus/common/repository/actual.kt @@ -1,6 +1,5 @@ package com.surrus.common.repository -import co.touchlab.kermit.LogcatLogger import co.touchlab.kermit.Logger import com.squareup.sqldelight.android.AndroidSqliteDriver import com.surrus.common.di.PeopleInSpaceDatabaseWrapper @@ -14,5 +13,4 @@ actual fun platformModule() = module { PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver)) } - single { LogcatLogger() } } diff --git a/common/src/commonMain/kotlin/com/surrus/common/di/Koin.kt b/common/src/commonMain/kotlin/com/surrus/common/di/Koin.kt index 34a9320..da6d87a 100644 --- a/common/src/commonMain/kotlin/com/surrus/common/di/Koin.kt +++ b/common/src/commonMain/kotlin/com/surrus/common/di/Koin.kt @@ -1,6 +1,5 @@ package com.surrus.common.di -import co.touchlab.kermit.Kermit import com.surrus.common.remote.PeopleInSpaceApi import com.surrus.common.repository.PeopleInSpaceRepository import com.surrus.common.repository.PeopleInSpaceRepositoryInterface @@ -35,7 +34,6 @@ fun commonModule(enableNetworkLogs: Boolean) = module { single { PeopleInSpaceRepository() } single { PeopleInSpaceApi(get()) } - single { Kermit(logger = get()) } } fun createJson() = Json { isLenient = true; ignoreUnknownKeys = true } diff --git a/common/src/commonMain/kotlin/com/surrus/common/repository/PeopleInSpaceRepository.kt b/common/src/commonMain/kotlin/com/surrus/common/repository/PeopleInSpaceRepository.kt index 821e3ed..7d3986e 100644 --- a/common/src/commonMain/kotlin/com/surrus/common/repository/PeopleInSpaceRepository.kt +++ b/common/src/commonMain/kotlin/com/surrus/common/repository/PeopleInSpaceRepository.kt @@ -1,6 +1,6 @@ package com.surrus.common.repository -import co.touchlab.kermit.Kermit +import co.touchlab.kermit.Logger import com.rickclephas.kmp.nativecoroutines.NativeCoroutineScope import com.squareup.sqldelight.runtime.coroutines.asFlow import com.squareup.sqldelight.runtime.coroutines.mapToList @@ -22,13 +22,14 @@ interface PeopleInSpaceRepositoryInterface { class PeopleInSpaceRepository : KoinComponent, PeopleInSpaceRepositoryInterface { private val peopleInSpaceApi: PeopleInSpaceApi by inject() - private val logger: Kermit by inject() @NativeCoroutineScope private val coroutineScope: CoroutineScope = MainScope() private val peopleInSpaceDatabase: PeopleInSpaceDatabaseWrapper by inject() private val peopleInSpaceQueries = peopleInSpaceDatabase.instance?.peopleInSpaceQueries + val logger = Logger.withTag("PeopleInSpaceRepository") + init { coroutineScope.launch { fetchAndStorePeople() @@ -77,12 +78,11 @@ class PeopleInSpaceRepository : KoinComponent, PeopleInSpaceRepositoryInterface // The returned will be frozen in Kotlin Native. We can't freeze the Koin internals // so we'll use local variables to prevent the Koin internals from freezing. val api = peopleInSpaceApi - val logger = logger return flow { while (true) { val position = api.fetchISSPosition().iss_position emit(position) - logger.d("PeopleInSpaceRepository") { position.toString() } + logger.d { position.toString() } delay(POLL_INTERVAL) } } diff --git a/common/src/iOSMain/kotlin/com/surrus/common/repository/actual.kt b/common/src/iOSMain/kotlin/com/surrus/common/repository/actual.kt index d9edffe..2a47dd2 100644 --- a/common/src/iOSMain/kotlin/com/surrus/common/repository/actual.kt +++ b/common/src/iOSMain/kotlin/com/surrus/common/repository/actual.kt @@ -1,7 +1,5 @@ package com.surrus.common.repository -import co.touchlab.kermit.Logger -import co.touchlab.kermit.NSLogLogger import com.squareup.sqldelight.drivers.native.NativeSqliteDriver import com.surrus.common.di.PeopleInSpaceDatabaseWrapper import com.surrus.peopleinspace.db.PeopleInSpaceDatabase @@ -12,5 +10,4 @@ actual fun platformModule() = module { val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db") PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver)) } - single { NSLogLogger() } } diff --git a/common/src/jsMain/kotlin/com/surrus/common/repository/actual.kt b/common/src/jsMain/kotlin/com/surrus/common/repository/actual.kt index 39ffb8a..1c3b8f9 100644 --- a/common/src/jsMain/kotlin/com/surrus/common/repository/actual.kt +++ b/common/src/jsMain/kotlin/com/surrus/common/repository/actual.kt @@ -1,7 +1,5 @@ package com.surrus.common.repository -import co.touchlab.kermit.CommonLogger -import co.touchlab.kermit.Logger import com.surrus.common.di.PeopleInSpaceDatabaseWrapper import org.koin.dsl.module @@ -9,6 +7,4 @@ actual fun platformModule() = module { single { PeopleInSpaceDatabaseWrapper(null) } - - single { CommonLogger() } } diff --git a/common/src/jvmMain/kotlin/com/surrus/common/repository/actual.kt b/common/src/jvmMain/kotlin/com/surrus/common/repository/actual.kt index f59f325..dc96fe0 100644 --- a/common/src/jvmMain/kotlin/com/surrus/common/repository/actual.kt +++ b/common/src/jvmMain/kotlin/com/surrus/common/repository/actual.kt @@ -1,7 +1,5 @@ package com.surrus.common.repository -import co.touchlab.kermit.CommonLogger -import co.touchlab.kermit.Logger import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver import com.surrus.common.di.PeopleInSpaceDatabaseWrapper import com.surrus.peopleinspace.db.PeopleInSpaceDatabase @@ -13,6 +11,4 @@ actual fun platformModule() = module { .also { PeopleInSpaceDatabase.Schema.create(it) } PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver)) } - - single { CommonLogger() } } diff --git a/common/src/macOSMain/kotlin/com/surrus/common/repository/actual.kt b/common/src/macOSMain/kotlin/com/surrus/common/repository/actual.kt index d9edffe..2a47dd2 100644 --- a/common/src/macOSMain/kotlin/com/surrus/common/repository/actual.kt +++ b/common/src/macOSMain/kotlin/com/surrus/common/repository/actual.kt @@ -1,7 +1,5 @@ package com.surrus.common.repository -import co.touchlab.kermit.Logger -import co.touchlab.kermit.NSLogLogger import com.squareup.sqldelight.drivers.native.NativeSqliteDriver import com.surrus.common.di.PeopleInSpaceDatabaseWrapper import com.surrus.peopleinspace.db.PeopleInSpaceDatabase @@ -12,5 +10,4 @@ actual fun platformModule() = module { val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db") PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver)) } - single { NSLogLogger() } } diff --git a/common/src/watchMain/kotlin/com/surrus/common/repository/actual.kt b/common/src/watchMain/kotlin/com/surrus/common/repository/actual.kt index d9edffe..2a47dd2 100644 --- a/common/src/watchMain/kotlin/com/surrus/common/repository/actual.kt +++ b/common/src/watchMain/kotlin/com/surrus/common/repository/actual.kt @@ -1,7 +1,5 @@ package com.surrus.common.repository -import co.touchlab.kermit.Logger -import co.touchlab.kermit.NSLogLogger import com.squareup.sqldelight.drivers.native.NativeSqliteDriver import com.surrus.common.di.PeopleInSpaceDatabaseWrapper import com.surrus.peopleinspace.db.PeopleInSpaceDatabase @@ -12,5 +10,4 @@ actual fun platformModule() = module { val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db") PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver)) } - single { NSLogLogger() } } diff --git a/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt b/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt index 12fa213..4d91430 100644 --- a/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt +++ b/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceApplication.kt @@ -2,7 +2,7 @@ package com.surrus.peopleinspace import android.app.Application import android.util.Log -import co.touchlab.kermit.Kermit +import co.touchlab.kermit.Logger import coil.ImageLoader import coil.util.CoilUtils import coil.util.DebugLogger @@ -19,7 +19,6 @@ import org.koin.core.logger.Level import org.koin.dsl.module class PeopleInSpaceApplication : Application(), KoinComponent { - private val logger: Kermit by inject() override fun onCreate() { super.onCreate() @@ -33,7 +32,7 @@ class PeopleInSpaceApplication : Application(), KoinComponent { modules(appModule) } - logger.d { "PeopleInSpaceApplication" } + Logger.d { "PeopleInSpaceApplication" } } } diff --git a/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceViewModel.kt b/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceViewModel.kt index 32739ca..a2be4e6 100644 --- a/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceViewModel.kt +++ b/wearApp/src/main/java/com/surrus/peopleinspace/PeopleInSpaceViewModel.kt @@ -2,9 +2,7 @@ package com.surrus.peopleinspace import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import co.touchlab.kermit.Kermit import com.surrus.common.remote.Assignment -import com.surrus.common.repository.PeopleInSpaceRepository import com.surrus.common.repository.PeopleInSpaceRepositoryInterface import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.stateIn diff --git a/web/src/main/kotlin/Main.kt b/web/src/main/kotlin/Main.kt index 7c1bb73..06d9992 100644 --- a/web/src/main/kotlin/Main.kt +++ b/web/src/main/kotlin/Main.kt @@ -1,4 +1,3 @@ -import co.touchlab.kermit.Kermit import com.surrus.common.di.initKoin import com.surrus.common.repository.PeopleInSpaceRepositoryInterface import kotlinx.coroutines.InternalCoroutinesApi @@ -10,12 +9,10 @@ import react.dom.render object AppDependencies : KoinComponent { val repository: PeopleInSpaceRepositoryInterface - val logger: Kermit init { initKoin() repository = get() - logger = get() } }