all: migrate logging to Napier

This commit is contained in:
Harsh Shandilya 2022-05-03 22:49:49 +05:30
parent 239cfb753f
commit 9b9e924475
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
7 changed files with 17 additions and 9 deletions

View file

@ -34,6 +34,7 @@ kotlin {
api(compose.material3)
api(projects.database)
api(projects.model)
api(libs.napier)
implementation(libs.kotlin.coroutines.core)
implementation(libs.compose.richtext.markdown)
implementation(libs.compose.richtext.material)

View file

@ -3,10 +3,10 @@ package dev.msfjarvis.claw.common.urllauncher
import android.content.ActivityNotFoundException
import android.content.Context
import android.net.Uri
import android.util.Log
import android.widget.Toast
import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.ui.platform.UriHandler
import io.github.aakira.napier.Napier
class UrlLauncher(private val context: Context) : UriHandler {
override fun openUri(uri: String) {
@ -20,7 +20,7 @@ class UrlLauncher(private val context: Context) : UriHandler {
customTabsIntent.launchUrl(context, Uri.parse(uri))
} catch (e: ActivityNotFoundException) {
val error = "Failed to open URL: $uri"
Log.d("UrlLauncher", error)
Napier.d(tag = "UrlLauncher") { error }
Toast.makeText(context, error, Toast.LENGTH_SHORT).show()
}
}

View file

@ -1,6 +1,7 @@
package dev.msfjarvis.claw.common.urllauncher
import androidx.compose.ui.platform.UriHandler
import io.github.aakira.napier.Napier
import java.awt.Desktop
import java.io.IOException
import java.net.URI
@ -13,7 +14,7 @@ class UrlLauncher : UriHandler {
try {
desktop.browse(URI(uri))
} catch (e: IOException) {
println("Failed to open URL: $uri")
Napier.d(tag = "UrlLauncher") { "Failed to open URL: $uri" }
}
}
}