mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
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:
parent
a927481e4d
commit
0776e029f3
92 changed files with 727 additions and 957 deletions
|
|
@ -21,11 +21,11 @@ import androidx.datastore.core.DataStore
|
|||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import co.touchlab.kermit.Logger
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.json.Json
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
@ -43,9 +43,9 @@ class BootloaderWarningDataSource @Inject constructor(private val dataStore: Dat
|
|||
runCatching { Json.decodeFromString<List<String>>(jsonString).toSet() }
|
||||
.onFailure { e ->
|
||||
if (e is IllegalArgumentException || e is SerializationException) {
|
||||
Timber.w(e, "Failed to parse dismissed bootloader warning addresses, resetting preference")
|
||||
Logger.w(e) { "Failed to parse dismissed bootloader warning addresses, resetting preference" }
|
||||
} else {
|
||||
Timber.w(e, "Unexpected error while parsing dismissed bootloader warning addresses")
|
||||
Logger.w(e) { "Unexpected error while parsing dismissed bootloader warning addresses" }
|
||||
}
|
||||
}
|
||||
.getOrDefault(emptySet())
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
package org.meshtastic.core.datastore
|
||||
|
||||
import androidx.datastore.core.DataStore
|
||||
import co.touchlab.kermit.Logger
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import org.meshtastic.proto.AppOnlyProtos.ChannelSet
|
||||
import org.meshtastic.proto.ChannelProtos.Channel
|
||||
import org.meshtastic.proto.ChannelProtos.ChannelSettings
|
||||
import org.meshtastic.proto.ConfigProtos
|
||||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
@ -36,7 +36,7 @@ class ChannelSetDataSource @Inject constructor(private val channelSetStore: Data
|
|||
channelSetStore.data.catch { exception ->
|
||||
// dataStore.data throws an IOException when an error is encountered when reading data
|
||||
if (exception is IOException) {
|
||||
Timber.e("Error reading DeviceConfig settings: ${exception.message}")
|
||||
Logger.e { "Error reading DeviceConfig settings: ${exception.message}" }
|
||||
emit(ChannelSet.getDefaultInstance())
|
||||
} else {
|
||||
throw exception
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@
|
|||
package org.meshtastic.core.datastore
|
||||
|
||||
import androidx.datastore.core.DataStore
|
||||
import co.touchlab.kermit.Logger
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import org.meshtastic.proto.ConfigProtos.Config
|
||||
import org.meshtastic.proto.LocalOnlyProtos.LocalConfig
|
||||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
@ -34,7 +34,7 @@ class LocalConfigDataSource @Inject constructor(private val localConfigStore: Da
|
|||
localConfigStore.data.catch { exception ->
|
||||
// dataStore.data throws an IOException when an error is encountered when reading data
|
||||
if (exception is IOException) {
|
||||
Timber.e("Error reading LocalConfig settings: ${exception.message}")
|
||||
Logger.e { "Error reading LocalConfig settings: ${exception.message}" }
|
||||
emit(LocalConfig.getDefaultInstance())
|
||||
} else {
|
||||
throw exception
|
||||
|
|
@ -53,7 +53,7 @@ class LocalConfigDataSource @Inject constructor(private val localConfigStore: Da
|
|||
if (localField != null) {
|
||||
builder.setField(localField, value)
|
||||
} else {
|
||||
Timber.e("Error writing LocalConfig settings: ${config.payloadVariantCase}")
|
||||
Logger.e { "Error writing LocalConfig settings: ${config.payloadVariantCase}" }
|
||||
}
|
||||
}
|
||||
builder.build()
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@
|
|||
package org.meshtastic.core.datastore
|
||||
|
||||
import androidx.datastore.core.DataStore
|
||||
import co.touchlab.kermit.Logger
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import org.meshtastic.proto.LocalOnlyProtos.LocalModuleConfig
|
||||
import org.meshtastic.proto.ModuleConfigProtos.ModuleConfig
|
||||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
|
@ -34,7 +34,7 @@ class ModuleConfigDataSource @Inject constructor(private val moduleConfigStore:
|
|||
moduleConfigStore.data.catch { exception ->
|
||||
// dataStore.data throws an IOException when an error is encountered when reading data
|
||||
if (exception is IOException) {
|
||||
Timber.e("Error reading LocalModuleConfig settings: ${exception.message}")
|
||||
Logger.e { "Error reading LocalModuleConfig settings: ${exception.message}" }
|
||||
emit(LocalModuleConfig.getDefaultInstance())
|
||||
} else {
|
||||
throw exception
|
||||
|
|
@ -53,7 +53,7 @@ class ModuleConfigDataSource @Inject constructor(private val moduleConfigStore:
|
|||
if (localField != null) {
|
||||
builder.setField(localField, value)
|
||||
} else {
|
||||
Timber.e("Error writing LocalModuleConfig settings: ${config.payloadVariantCase}")
|
||||
Logger.e { "Error writing LocalModuleConfig settings: ${config.payloadVariantCase}" }
|
||||
}
|
||||
}
|
||||
builder.build()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import androidx.datastore.core.DataStore
|
|||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import co.touchlab.kermit.Logger
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
|
@ -29,7 +30,6 @@ import kotlinx.serialization.json.Json
|
|||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.meshtastic.core.datastore.model.RecentAddress
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
@ -46,11 +46,11 @@ class RecentAddressesDataSource @Inject constructor(private val dataStore: DataS
|
|||
try {
|
||||
Json.decodeFromString<List<RecentAddress>>(jsonString)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Timber.w("Could not parse recent addresses, falling back to legacy parsing: ${e.message}")
|
||||
Logger.w { "Could not parse recent addresses, falling back to legacy parsing: ${e.message}" }
|
||||
// Fallback to legacy parsing
|
||||
parseLegacyRecentAddresses(jsonString)
|
||||
} catch (e: SerializationException) {
|
||||
Timber.w("Could not parse recent addresses, falling back to legacy parsing: ${e.message}")
|
||||
Logger.w { "Could not parse recent addresses, falling back to legacy parsing: ${e.message}" }
|
||||
// Fallback to legacy parsing
|
||||
parseLegacyRecentAddresses(jsonString)
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ class RecentAddressesDataSource @Inject constructor(private val dataStore: DataS
|
|||
}
|
||||
else -> {
|
||||
// Unknown format, log or handle as an error if necessary
|
||||
Timber.w("Unknown item type in recent IP addresses: $item")
|
||||
Logger.w { "Unknown item type in recent IP addresses: $item" }
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue