refactor: replace Napier with plain android.util.Log
This commit is contained in:
@@ -98,7 +98,6 @@ dependencies {
|
||||
implementation(libs.metrox.android)
|
||||
implementation(libs.metrox.viewmodel)
|
||||
implementation(libs.metrox.viewmodel.compose)
|
||||
implementation(libs.napier)
|
||||
implementation(libs.okhttp.core)
|
||||
implementation(libs.okhttp.loggingInterceptor)
|
||||
implementation(libs.retrofit)
|
||||
@@ -115,7 +114,6 @@ dependencies {
|
||||
implementation(projects.model)
|
||||
|
||||
debugImplementation(libs.androidx.compose.glance.appwidget.preview)
|
||||
debugImplementation(libs.napier.android.debug)
|
||||
|
||||
compileOnly(libs.androidx.compose.glance.preview)
|
||||
|
||||
|
||||
+3
-3
@@ -6,11 +6,11 @@
|
||||
*/
|
||||
package dev.msfjarvis.claw.android.injection
|
||||
|
||||
import android.util.Log
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.BindingContainer
|
||||
import dev.zacsweers.metro.ContributesTo
|
||||
import dev.zacsweers.metro.Provides
|
||||
import io.github.aakira.napier.Napier
|
||||
import me.saket.unfurl.UnfurlLogger
|
||||
import me.saket.unfurl.Unfurler
|
||||
import okhttp3.OkHttpClient
|
||||
@@ -22,11 +22,11 @@ object MetadataExtractorModule {
|
||||
fun provideUnfurlLogger(): UnfurlLogger {
|
||||
return object : UnfurlLogger {
|
||||
override fun log(message: String) {
|
||||
Napier.d(tag = "Unfurler") { message }
|
||||
Log.d("Unfurler", message)
|
||||
}
|
||||
|
||||
override fun log(e: Throwable, message: String) {
|
||||
Napier.e(tag = "Unfurler", throwable = e) { message }
|
||||
Log.e("Unfurler", message, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-4
@@ -6,8 +6,10 @@
|
||||
*/
|
||||
package dev.msfjarvis.claw.android.viewmodel
|
||||
|
||||
import android.util.Log
|
||||
import app.cash.sqldelight.coroutines.asFlow
|
||||
import app.cash.sqldelight.coroutines.mapToList
|
||||
import dev.msfjarvis.claw.android.BuildConfig
|
||||
import dev.msfjarvis.claw.core.coroutines.DatabaseReadDispatcher
|
||||
import dev.msfjarvis.claw.core.coroutines.DatabaseWriteDispatcher
|
||||
import dev.msfjarvis.claw.database.local.SavedPost
|
||||
@@ -15,7 +17,6 @@ import dev.msfjarvis.claw.database.local.SavedPostQueries
|
||||
import dev.msfjarvis.claw.model.UIPost
|
||||
import dev.msfjarvis.claw.model.toSavedPost
|
||||
import dev.zacsweers.metro.Inject
|
||||
import io.github.aakira.napier.Napier
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -39,16 +40,22 @@ class SavedPostsRepository(
|
||||
val exists =
|
||||
withContext(readDispatcher) { savedPostQueries.postExists(post.shortId).executeAsOne() }
|
||||
if (exists) {
|
||||
Napier.d(tag = TAG) { "Removing post: ${post.shortId}" }
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(TAG, "Removing post: ${post.shortId}")
|
||||
}
|
||||
withContext(writeDispatcher) { savedPostQueries.deletePost(post.shortId) }
|
||||
} else {
|
||||
Napier.d(tag = TAG) { "Saving post: ${post.shortId}" }
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(TAG, "Saving post: ${post.shortId}")
|
||||
}
|
||||
withContext(writeDispatcher) { savedPostQueries.insertOrReplacePost(post.toSavedPost()) }
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun savePosts(posts: List<SavedPost>) {
|
||||
Napier.d(tag = TAG) { "Saving posts: ${posts.joinToString(",") { it.shortId }}" }
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(TAG, "Saving posts: ${posts.joinToString(",") { it.shortId }}")
|
||||
}
|
||||
withContext(writeDispatcher) {
|
||||
savedPostQueries.transaction {
|
||||
posts.forEach { post -> savedPostQueries.insertOrReplacePost(post) }
|
||||
|
||||
@@ -68,11 +68,8 @@ dependencies {
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.metrox.viewmodel)
|
||||
implementation(libs.metrox.viewmodel.compose)
|
||||
implementation(libs.napier)
|
||||
implementation(libs.sqldelight.runtime)
|
||||
|
||||
debugImplementation(libs.napier.android.debug)
|
||||
|
||||
compileOnly(libs.androidx.compose.ui.tooling.preview)
|
||||
|
||||
runtimeOnly(libs.androidx.compose.ui.tooling)
|
||||
|
||||
+6
-4
@@ -7,6 +7,7 @@
|
||||
package dev.msfjarvis.claw.common.persistence
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.datastore.core.DataMigration
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.core.DataStoreFactory
|
||||
@@ -20,7 +21,6 @@ import dev.zacsweers.metro.BindingContainer
|
||||
import dev.zacsweers.metro.ContributesTo
|
||||
import dev.zacsweers.metro.IntoSet
|
||||
import dev.zacsweers.metro.Provides
|
||||
import io.github.aakira.napier.Napier
|
||||
|
||||
@BindingContainer
|
||||
@ContributesTo(AppScope::class)
|
||||
@@ -33,9 +33,11 @@ object PreferencesStoreModule {
|
||||
return DataStoreFactory.create(
|
||||
corruptionHandler =
|
||||
ReplaceFileCorruptionHandler {
|
||||
Napier.d(throwable = it) {
|
||||
"Preferences data store corruption detected, returning empty preferences."
|
||||
}
|
||||
Log.d(
|
||||
"PreferencesStore",
|
||||
"Preferences data store corruption detected, returning empty preferences.",
|
||||
it,
|
||||
)
|
||||
emptyPreferences()
|
||||
},
|
||||
migrations = migrations.toList(),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package dev.msfjarvis.claw.common.ui
|
||||
|
||||
import android.content.ClipData
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -28,12 +29,11 @@ import androidx.compose.ui.platform.LocalClipboard
|
||||
import androidx.compose.ui.unit.dp
|
||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||
import dev.msfjarvis.claw.common.ui.preview.ThemePreviews
|
||||
import io.github.aakira.napier.Napier
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun NetworkError(label: String, error: Throwable, modifier: Modifier = Modifier) {
|
||||
LaunchedEffect(Unit) { Napier.e(error, "NetworkError") { "Failed to load posts" } }
|
||||
LaunchedEffect(Unit) { Log.e("NetworkError", "Failed to load posts", error) }
|
||||
var showDialog by remember { mutableStateOf(false) }
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = modifier) {
|
||||
Text(
|
||||
|
||||
@@ -9,6 +9,7 @@ package dev.msfjarvis.claw.common.urllauncher
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.compose.ui.platform.UriHandler
|
||||
@@ -16,7 +17,6 @@ import androidx.core.net.toUri
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import dev.zacsweers.metro.Inject
|
||||
import io.github.aakira.napier.Napier
|
||||
|
||||
@Inject
|
||||
@ContributesBinding(AppScope::class)
|
||||
@@ -37,7 +37,7 @@ class UrlLauncher(private val context: Context) : UriHandler {
|
||||
context.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
val error = "Failed to open URL: $uri"
|
||||
Napier.d(throwable = e, tag = "UrlLauncher") { error }
|
||||
Log.d("UrlLauncher", error, e)
|
||||
Toast.makeText(context, error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ dependencies {
|
||||
api(libs.kotlinx.coroutines.core)
|
||||
api(libs.kotlinx.serialization.json)
|
||||
api(libs.metrox.viewmodel)
|
||||
api(libs.napier)
|
||||
api(libs.okhttp.core)
|
||||
api(libs.okhttp.loggingInterceptor)
|
||||
api(libs.retrofit)
|
||||
@@ -27,6 +26,4 @@ dependencies {
|
||||
implementation(platform(libs.okhttp.bom))
|
||||
implementation(libs.kotlinx.serialization.core)
|
||||
implementation(libs.retrofit.kotlinxSerializationConverter)
|
||||
|
||||
debugImplementation(libs.napier.android.debug)
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright © Harsh Shandilya.
|
||||
* Use of this source code is governed by an MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*/
|
||||
package dev.msfjarvis.claw.core.logging
|
||||
|
||||
import android.app.Application
|
||||
import dev.msfjarvis.claw.core.injection.AppPlugin
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesIntoSet
|
||||
import dev.zacsweers.metro.Inject
|
||||
import io.github.aakira.napier.DebugAntilog
|
||||
import io.github.aakira.napier.Napier
|
||||
|
||||
@ContributesIntoSet(AppScope::class)
|
||||
@Inject
|
||||
class NapierPlugin() : AppPlugin {
|
||||
override fun apply(application: Application) {
|
||||
Napier.base(DebugAntilog())
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -6,17 +6,17 @@
|
||||
*/
|
||||
package dev.msfjarvis.claw.core.network
|
||||
|
||||
import android.util.Log
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import dev.zacsweers.metro.Inject
|
||||
import io.github.aakira.napier.Napier
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
|
||||
/** Implementation of [HttpLoggingInterceptor.Logger] backed by [Napier]. */
|
||||
/** Implementation of [HttpLoggingInterceptor.Logger] backed by [Log]. */
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
class NapierLogger : HttpLoggingInterceptor.Logger {
|
||||
class OkHttpLogger : HttpLoggingInterceptor.Logger {
|
||||
override fun log(message: String) {
|
||||
Napier.d(tag = "LobstersApi") { message }
|
||||
Log.d("LobstersApi", message)
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,11 @@ dependencies {
|
||||
api(projects.database.core)
|
||||
|
||||
implementation(libs.androidx.sqlite)
|
||||
implementation(libs.napier)
|
||||
implementation(libs.sqldelight.androidDriver)
|
||||
implementation(libs.sqldelight.primitiveAdapters)
|
||||
implementation(libs.sqlite.android)
|
||||
implementation(libs.sentry.android.sqlite)
|
||||
|
||||
debugImplementation(libs.napier.android.debug)
|
||||
|
||||
testImplementation(libs.sqldelight.jvmDriver)
|
||||
testImplementation(libs.sqldelight.runtime)
|
||||
|
||||
|
||||
+2
-2
@@ -7,6 +7,7 @@
|
||||
package dev.msfjarvis.claw.database.injection
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import app.cash.sqldelight.adapter.primitive.IntColumnAdapter
|
||||
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
|
||||
@@ -20,7 +21,6 @@ import dev.zacsweers.metro.BindingContainer
|
||||
import dev.zacsweers.metro.ContributesTo
|
||||
import dev.zacsweers.metro.Provides
|
||||
import dev.zacsweers.metro.SingleIn
|
||||
import io.github.aakira.napier.Napier
|
||||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||
import io.requery.android.database.sqlite.SQLiteDatabase
|
||||
import io.sentry.android.sqlite.SentrySupportSQLiteOpenHelper
|
||||
@@ -55,7 +55,7 @@ object DatabaseModule {
|
||||
},
|
||||
)
|
||||
) { message ->
|
||||
Napier.d(tag = "SQLDelightQuery", message = message)
|
||||
Log.d("SQLDelightQuery", message)
|
||||
}
|
||||
return LobstersDatabase(
|
||||
driver = driver,
|
||||
|
||||
@@ -20,7 +20,6 @@ kotlin = "2.3.0"
|
||||
kotlinResult = "2.1.0"
|
||||
lifecycle = "2.10.0"
|
||||
metro = "0.9.3"
|
||||
napier = "2.7.1"
|
||||
navigation3 = "1.0.0"
|
||||
navigation3-material = "1.3.0-alpha05"
|
||||
paging = "3.3.6"
|
||||
@@ -124,8 +123,6 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa
|
||||
metrox-android = { module = "dev.zacsweers.metro:metrox-android", version.ref = "metro" }
|
||||
metrox-viewmodel = { module = "dev.zacsweers.metro:metrox-viewmodel", version.ref = "metro" }
|
||||
metrox-viewmodel-compose = { module = "dev.zacsweers.metro:metrox-viewmodel-compose", version.ref = "metro" }
|
||||
napier = { module = "io.github.aakira:napier", version.ref = "napier" }
|
||||
napier-android-debug = { module = "io.github.aakira:napier-android-debug", version.ref = "napier" }
|
||||
okhttp-bom = "com.squareup.okhttp3:okhttp-bom:5.3.2"
|
||||
okhttp-core = { module = "com.squareup.okhttp3:okhttp" }
|
||||
okhttp-loggingInterceptor = { module = "com.squareup.okhttp3:logging-interceptor" }
|
||||
|
||||
Reference in New Issue
Block a user