Skip to content

Commit

Permalink
Define a logger
Browse files Browse the repository at this point in the history
  • Loading branch information
guiBrisson committed Mar 21, 2024
1 parent f459237 commit 92ec12a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ kotlin {
implementation(libs.precompose.navigation)
implementation(libs.precompose.viewmodel)
implementation(libs.precompose.koin)
implementation(libs.kermit)
implementation(libs.koin.core)
implementation(libs.multiplatform.settings)
implementation(libs.sqldelight.runtime)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package data.datasource.local

import co.touchlab.kermit.Logger
import com.russhwolf.settings.Settings
import com.russhwolf.settings.set
import data.datasource.BalanceDataSource
Expand All @@ -10,6 +11,7 @@ import kotlinx.coroutines.withContext

class LocalBalanceDataSource : BalanceDataSource {
private val settings: Settings = Settings()
private val log = Logger.withTag(this::class.simpleName ?: "LocalBalanceDataSource")

override suspend fun getUsersBalance(): Balance = withContext(Dispatchers.IO) {
val usersBalance: String = settings.getString(BALANCE_KEY, BALANCE_DEFAULT_VALUE)
Expand All @@ -18,6 +20,7 @@ class LocalBalanceDataSource : BalanceDataSource {

override suspend fun updateUsersBalance(balance: Balance) = withContext(Dispatchers.IO) {
settings[BALANCE_KEY] = balance.toString()
log.i("Update users balance: $balance")
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package data.datasource.local

import co.touchlab.kermit.Logger
import com.github.guibrisson.db.MoneyMateDatabase
import data.datasource.OperationDataSource
import domain.model.Category
Expand All @@ -12,6 +13,7 @@ import org.koin.core.component.inject
class LocalOperationDataSource: KoinComponent, OperationDataSource {
private val databaseWrapper: DatabaseWrapper by inject()
private val database: MoneyMateDatabase = databaseWrapper.instance()
private val log = Logger.withTag(this::class.simpleName ?: "LocalOperationDataSource")

override suspend fun getById(id: Int): Result<Operation> {
//TODO remove this later, mocked for now
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ androidx-test-junit = "1.1.5"
compose = "1.6.2"
compose-plugin = "1.6.0"
junit = "4.13.2"
kermit = "2.0.3"
kotlin = "1.9.22"
kotlinx-datetime = "0.6.0-RC.2"
koin = "3.5.3"
Expand All @@ -27,6 +28,7 @@ androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-co
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
kermit = { group = "co.touchlab", name = "kermit", version.ref = "kermit" }
koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koin" }
koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" }
Expand Down

0 comments on commit 92ec12a

Please sign in to comment.