Skip to content
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

Logs Not Appearing in Firebase Crashlytics with Kermit in Kotlin Multiplatform Using GitLive Firebase SDK #407

Open
mhristev opened this issue Oct 18, 2024 · 0 comments

Comments

@mhristev
Copy link

mhristev commented Oct 18, 2024

I’m using the GitLive Firebase SDK in a Kotlin Multiplatform project and have integrated Kermit for logging. The logs, including exceptions, appear in Logcat, but they are not being sent to Firebase Crashlytics. I’m using CrashlyticsLogWriter() to route logs from Kermit to Crashlytics in Android-specific code.

build.gradle in shared:

sourceSets {
        commonMain.dependencies {
            api(libs.gitlive.firebase.kotlin.crashlytics)
            implementation("co.touchlab:kermit:2.0.4")
            implementation("co.touchlab:kermit-crashlytics:2.0.4")
            implementation("co.touchlab.crashkios:crashlytics:0.9.0")
        }
    }

androidMain:

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        SharedLogger.initializeCrashlyticsLogging()
        SharedLogger.logInfo("In the onCreate()")

        setContent {
            App()
        }
    }
}

SharedLogger in commonMain

object SharedLogger {
    val logger: Logger = Logger.withTag("SharedLogger")

    @OptIn(ExperimentalKermitApi::class)
    fun initializeCrashlyticsLogging() {
        Logger.addLogWriter(CrashlyticsLogWriter())
        logInfo("In the init in shared")
    }


    fun logError(exception: Throwable, message: String) {
        logger.e(exception) { message }
    }

    fun triggerEveryTypeOfSeverityLog() {
        logger.v { "This is a verbose log message" }
        logger.d { "This is a debug log message" }
        logger.i { "This is an info log message" }
        logger.w { "This is a warning log message" }
        logger.e { "This is an error log message" }
        logger.a { "This is an assert log message" }
    }

    fun logInfo(message: String) {
        logger.i { message }
    }
}

I am trying to call triggerCrashOutOfBounds() which is in shared/commonMain, from the Android UI:

fun triggerCrashOutOfBounds() {
    val myList = listOf(1, 2, 3)
    SharedLogger.logInfo("Calling triggerCrashOutOfBounds().")
    try {
        val element = myList[5] 
    } catch (e: IndexOutOfBoundsException) {
        SharedLogger.logError(e, "Out of bounds error occurred.")

        throw e
    }
}

In the Crashlytics page in Firebase I can see only:

1. Info: (SharedLogger) In the onCreate()

2. Info: (SharedLogger) In the init in shared

The logs from the triggerCrashOutOfBounds are completely lost. Any ideas? (iOS can send all the logs to Crashlytics, even those from triggerCrashOutOfBounds )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant