KSLog/src/jsMain/kotlin/ActualLogger.kt

16 lines
487 B
Kotlin
Raw Permalink Normal View History

2022-06-07 14:02:59 +00:00
package dev.inmo.kslog.common
2022-06-07 13:26:11 +00:00
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit = { l, t, m, e ->
2022-06-07 15:52:42 +00:00
val args = e ?.let {
2022-06-09 10:29:56 +00:00
arrayOf(m, e)
} ?: arrayOf(m)
2022-06-07 13:26:11 +00:00
when (l) {
2022-06-08 15:45:37 +00:00
LogLevel.DEBUG -> console.log(*args)
2022-06-07 13:26:11 +00:00
LogLevel.VERBOSE,
2022-06-07 15:52:42 +00:00
LogLevel.INFO -> console.info(*args)
LogLevel.WARNING -> console.warn(*args)
2022-06-07 13:26:11 +00:00
LogLevel.ERROR,
2022-06-07 15:52:42 +00:00
LogLevel.ASSERT -> console.error(*args)
2022-06-07 13:26:11 +00:00
}
}