mirror of
https://github.com/InsanusMokrassar/KSLog.git
synced 2026-11-10 21:42:55 +00:00
a lot of changes and improvements
This commit is contained in:
1 parent
81b32b0119
commit
0348756729
21 files changed
+99
-64
No files matched your search
@@ -1,16 +0,0 @@
|
||||
package dev.inmo.kslog.common
|
||||
|
||||
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit = { l, t, m, e ->
|
||||
val args = e ?.let {
|
||||
arrayOf(m, e)
|
||||
} ?: arrayOf(m)
|
||||
when (l) {
|
||||
LogLevel.TRACE,
|
||||
LogLevel.DEBUG -> console.log(*args)
|
||||
LogLevel.VERBOSE,
|
||||
LogLevel.INFO -> console.info(*args)
|
||||
LogLevel.WARNING -> console.warn(*args)
|
||||
LogLevel.ERROR,
|
||||
LogLevel.ASSERT -> console.error(*args)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.inmo.kslog.common
|
||||
|
||||
import kotlin.js.Console
|
||||
|
||||
external interface ExtendedConsole : Console {
|
||||
fun trace()
|
||||
fun debug(vararg o: Any?)
|
||||
fun assert(vararg o: Any?)
|
||||
}
|
||||
|
||||
/**
|
||||
* [https://developer.mozilla.org/en-US/docs/Web/API/console/debug_static](https://developer.mozilla.org/en-US/docs/Web/API/console/debug_static)
|
||||
*/
|
||||
fun Console.debug(vararg args: Any?) = unsafeCast<ExtendedConsole>().debug(*args)
|
||||
|
||||
/**
|
||||
* [https://developer.mozilla.org/en-US/docs/Web/APtraceI/console/assert_static](https://developer.mozilla.org/en-US/docs/Web/API/console/assert_static)
|
||||
*/
|
||||
fun Console.assert(vararg args: Any?) = unsafeCast<ExtendedConsole>().assert(*args)
|
||||
|
||||
/**
|
||||
* [https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static](https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static)
|
||||
*/
|
||||
fun Console.trace() = unsafeCast<ExtendedConsole>().trace()
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.kslog.common
|
||||
|
||||
actual var KSLoggerDefaultPlatformLoggerLambda: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit = { l, _, m, e ->
|
||||
val args = e ?.let {
|
||||
arrayOf(m, e)
|
||||
} ?: arrayOf(m)
|
||||
when (l) {
|
||||
LogLevel.TRACE -> {
|
||||
console.trace()
|
||||
console.debug(*args)
|
||||
}
|
||||
LogLevel.DEBUG -> console.debug(*args)
|
||||
LogLevel.VERBOSE,
|
||||
LogLevel.INFO -> console.info(*args)
|
||||
LogLevel.WARNING -> console.warn(*args)
|
||||
LogLevel.ERROR -> console.error(*args)
|
||||
LogLevel.ASSERT -> console.assert(*args)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user