All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.multiplatform.webview.util.KLogger.kt Maven / Gradle / Ivy

There is a newer version: 1.9.40-alpha04
Show newest version
package com.multiplatform.webview.util

import co.touchlab.kermit.DefaultFormatter
import co.touchlab.kermit.Logger
import co.touchlab.kermit.Severity
import co.touchlab.kermit.mutableLoggerConfigInit
import co.touchlab.kermit.platformLogWriter

/**
 * Created By Kevin Zou On 2023/10/16
 */
internal object KLogger : Logger(
    config = mutableLoggerConfigInit(listOf(platformLogWriter(DefaultFormatter))),
    tag = "ComposeWebView",
) {
    init {
        setMinSeverity(KLogSeverity.Info)
    }

    fun setMinSeverity(severity: KLogSeverity) {
        mutableConfig.minSeverity = severity.toKermitSeverity()
    }
}

enum class KLogSeverity {
    Verbose,
    Debug,
    Info,
    Warn,
    Error,
    Assert,
}

fun KLogSeverity.toKermitSeverity(): Severity {
    return when (this) {
        KLogSeverity.Verbose -> Severity.Verbose
        KLogSeverity.Debug -> Severity.Debug
        KLogSeverity.Info -> Severity.Info
        KLogSeverity.Warn -> Severity.Warn
        KLogSeverity.Error -> Severity.Error
        KLogSeverity.Assert -> Severity.Assert
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy