feat(logging): Replace Timber with Kermit for multiplatform logging (#4083)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-12-28 08:30:15 -06:00 committed by GitHub
parent a927481e4d
commit 0776e029f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
92 changed files with 727 additions and 957 deletions

View file

@ -23,6 +23,7 @@ import androidx.appcompat.app.AppCompatActivity.BIND_AUTO_CREATE
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import co.touchlab.kermit.Logger
import com.geeksville.mesh.android.BindFailedException
import com.geeksville.mesh.android.ServiceClient
import com.geeksville.mesh.concurrent.SequentialJob
@ -32,7 +33,6 @@ import dagger.hilt.android.qualifiers.ActivityContext
import dagger.hilt.android.scopes.ActivityScoped
import org.meshtastic.core.service.IMeshService
import org.meshtastic.core.service.ServiceRepository
import timber.log.Timber
import javax.inject.Inject
/** A Activity-lifecycle-aware [ServiceClient] that binds [MeshService] once the Activity is started. */
@ -49,7 +49,7 @@ constructor(
private val lifecycleOwner: LifecycleOwner = context as LifecycleOwner
init {
Timber.d("Adding self as LifecycleObserver for $lifecycleOwner")
Logger.d { "Adding self as LifecycleObserver for $lifecycleOwner" }
lifecycleOwner.lifecycle.addObserver(this)
}
@ -58,7 +58,7 @@ constructor(
override fun onConnected(service: IMeshService) {
serviceSetupJob.launch(lifecycleOwner.lifecycleScope) {
serviceRepository.setMeshService(service)
Timber.d("connected to mesh service, connectionState=${serviceRepository.connectionState.value}")
Logger.d { "connected to mesh service, connectionState=${serviceRepository.connectionState.value}" }
}
}
@ -73,32 +73,32 @@ constructor(
override fun onStart(owner: LifecycleOwner) {
super.onStart(owner)
Timber.d("Lifecycle: ON_START")
Logger.d { "Lifecycle: ON_START" }
try {
bindMeshService()
} catch (ex: BindFailedException) {
Timber.e("Bind of MeshService failed: ${ex.message}")
Logger.e { "Bind of MeshService failed: ${ex.message}" }
}
}
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
Timber.d("Lifecycle: ON_DESTROY")
Logger.d { "Lifecycle: ON_DESTROY" }
owner.lifecycle.removeObserver(this)
Timber.d("Removed self as LifecycleObserver to $lifecycleOwner")
Logger.d { "Removed self as LifecycleObserver to $lifecycleOwner" }
}
// endregion
@Suppress("TooGenericExceptionCaught")
private fun bindMeshService() {
Timber.d("Binding to mesh service!")
Logger.d { "Binding to mesh service!" }
try {
MeshService.startService(context)
} catch (ex: Exception) {
Timber.e("Failed to start service from activity - but ignoring because bind will work: ${ex.message}")
Logger.e { "Failed to start service from activity - but ignoring because bind will work: ${ex.message}" }
}
connect(context, MeshService.createIntent(context), BIND_AUTO_CREATE + BIND_ABOVE_CLIENT)