use Koin for logger

This commit is contained in:
John O'Reilly 2021-04-30 18:44:14 +01:00
parent aff4b8e0ca
commit ebc83fc535
8 changed files with 9 additions and 14 deletions

View file

@ -14,6 +14,6 @@ actual fun platformModule() = module {
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
}
single<Logger>{ LogcatLogger() }
}
actual fun getLogger(): Logger = LogcatLogger()

View file

@ -3,7 +3,6 @@ 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.getLogger
import com.surrus.common.repository.platformModule
import io.ktor.client.*
import io.ktor.client.features.json.*
@ -28,7 +27,7 @@ fun commonModule(enableNetworkLogs: Boolean) = module {
single { createHttpClient(get(), enableNetworkLogs = enableNetworkLogs) }
single { PeopleInSpaceRepository() }
single { PeopleInSpaceApi(get()) }
single { Kermit(getLogger()) }
single { Kermit(logger = get()) }
}
fun createJson() = Json { isLenient = true; ignoreUnknownKeys = true }

View file

@ -1,8 +1,6 @@
package com.surrus.common.repository
import co.touchlab.kermit.Logger
import org.koin.core.module.Module
expect fun platformModule(): Module
expect fun getLogger(): Logger

View file

@ -12,6 +12,5 @@ actual fun platformModule() = module {
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
}
single<Logger>{ NSLogLogger() }
}
actual fun getLogger(): Logger = NSLogLogger()

View file

@ -10,6 +10,6 @@ actual fun platformModule() = module {
single {
PeopleInSpaceDatabaseWrapper(null)
}
}
actual fun getLogger(): Logger = CommonLogger()
single<Logger>{ CommonLogger() }
}

View file

@ -7,12 +7,12 @@ import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
import org.koin.dsl.module
actual fun getLogger(): Logger = CommonLogger()
actual fun platformModule() = module {
single {
val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
.also { PeopleInSpaceDatabase.Schema.create(it) }
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
}
single<Logger>{ CommonLogger() }
}

View file

@ -12,6 +12,6 @@ actual fun platformModule() = module {
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
}
single<Logger>{ NSLogLogger() }
}
actual fun getLogger(): Logger = NSLogLogger()

View file

@ -12,7 +12,6 @@ actual fun platformModule() = module {
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
}
single<Logger>{ NSLogLogger() }
}
actual fun getLogger(): Logger = NSLogLogger()