Skip to content

Integrate Kermit for logging #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
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
2 changes: 2 additions & 0 deletions Fruitties/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ skie = "0.10.2"
sqlite = "2.5.1"
spotless = "7.0.4"
okio = "3.12.0"
kermit = "2.0.4"
runner = "1.6.2"
core = "1.6.1"
junit = "1.2.1"
Expand Down Expand Up @@ -74,6 +75,7 @@ androidx-navigation3-runtime = { module = "androidx.navigation3:navigation3-runt
androidx-navigation3-ui = { module = "androidx.navigation3:navigation3-ui", version.ref = "nav3Core" }
androidx-lifecycle-viewmodel-navigation3 = { module = "androidx.lifecycle:lifecycle-viewmodel-navigation3", version.ref = "lifecycleViewmodelNav3" }
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinxSerializationCore" }
kermit = { module = "co.touchlab:kermit", version.ref = "kermit" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
Expand Down
1 change: 1 addition & 0 deletions Fruitties/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ kotlin {
api(libs.androidx.datastore.preferences.core)
api(libs.androidx.datastore.core.okio)
implementation(libs.okio)
implementation(libs.kermit)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.example.fruitties.viewmodel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import co.touchlab.kermit.Logger
import com.example.fruitties.DataRepository
import com.example.fruitties.model.CartItemDetails
import kotlinx.coroutines.flow.SharingStarted
Expand All @@ -30,6 +31,18 @@ class CartViewModel(
private val repository: DataRepository,
) : ViewModel() {

<<<<<<< kermit
init {
Logger.i { "CartViewModel created" }
}

override fun onCleared() {
super.onCleared()
Logger.i { "CartViewModel cleared" }
}

=======
>>>>>>> mlykotom/ios-viewmodel-scoping
val cartUiState: StateFlow<CartUiState> =
repository.cartDetails
.map { details ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.example.fruitties.viewmodel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import co.touchlab.kermit.Logger
import com.example.fruitties.DataRepository
import com.example.fruitties.model.Fruittie
import kotlinx.coroutines.flow.SharingStarted
Expand All @@ -32,7 +33,12 @@ class MainViewModel(
) : ViewModel() {

init {
println("hello from ios!")
Logger.i { "MainViewModel created" }
}

override fun onCleared() {
super.onCleared()
Logger.i { "MainViewModel cleared" }
}

val homeUiState: StateFlow<HomeUiState> =
Expand Down
Loading