Hi, can someone tell me what happened with sentry ...
# touchlab-tools
p
Hi, can someone tell me what happened with sentry and kermit? I found this PR: https://github.com/touchlab/Kermit/pull/223 and tried to use
co.touchlab:kermit-sentry:2.0.2
, but this package do not exist. Do I need to use different version or sentry is no longer supported?
k
we did a reorg and moved a lot of the crash code back into CrashKiOS. The Sentry support wasn't great. We had run into weird issues. Also, Sentry had released an "official" library, so I figured we'd drop Kermit's version, and add in log writers for the Sentry client. However, progress on the Sentry client seems to have taken longer than expected. I should get it back on the todo list, though.
p
thanks for explanation. We are using the KMP sentry. What we are currently missing is the log writer integration in kermit, so logs from kermit will be visible in sentry. We are passing logs to platform in lambda and use timber for now, but would be awesome to switch to kermit fully 🙂
k
Well, I mean, it's a simple interface. I haven't really used the Sentry client, but my guess is the Kermit
LogWriter
would look something like this:
Copy code
class SentryLogWriter(
    private val messageStringFormatter: MessageStringFormatter = DefaultFormatter
) : LogWriter() {

    override fun isLoggable(tag: String, severity: Severity): Boolean = severity >= Severity.Warn // However you want to limit Sentry logs, if at all

    override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
        val formattedLogMessage = messageStringFormatter.formatMessage(severity, Tag(tag), Message(message))

        Sentry.addBreadcrumb(Breadcrumb(message = formattedLogMessage))
        
        if (throwable != null) {
            Sentry.captureException(throwable)
        }
    }
}
Then just add that to your Kermit setup
p
🙂 I was planning doing that. thanks
👍 1
for future readers. I made a custom SentryLogWriter(very similar to above) and it works great. Now, we have native sentry in android and iOS source codes and KMP sentry in shared module. Kermit logs to sentry on release builds and make normal logcat writes on debug. Important note. Remember to disable logcat sentry support for release build, cause sentry is picking these logs automatically which results in double logging. 🙂
👍 1