mirror of
https://github.com/InsanusMokrassar/KSLog.git
synced 2024-12-22 14:07:15 +00:00
fixes
This commit is contained in:
parent
b47104227c
commit
aad75a66b7
26
build.gradle
26
build.gradle
@ -33,7 +33,7 @@ repositories {
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js (IR) {
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
@ -47,30 +47,6 @@ kotlin {
|
||||
implementation libs.kotlin
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.common
|
||||
implementation libs.kotlin.test.annotations.common
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.js
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
androidTest {
|
||||
dependencies {
|
||||
implementation libs.kotlin.test.junit
|
||||
implementation libs.android.test.junit
|
||||
implementation libs.android.test.espresso.core
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package dev.inmo.kslog.common
|
||||
|
||||
inline fun Logger.log(level: LogLevel, tag: String? = null, e: Throwable? = null, messageBuilder: () -> String) = log(level, messageBuilder(), tag, e)
|
||||
inline fun Logger.log(level: LogLevel, tag: String? = null, e: Throwable? = null, messageBuilder: () -> String) = invoke(level, tag, messageBuilder(), e)
|
||||
inline fun Logger.log(level: LogLevel, message: String, e: Throwable? = null) = log(level, null, e) { message }
|
||||
inline fun Logger.log(level: LogLevel, tag: String, message: String, e: Throwable? = null) = log(level, tag, e) { message }
|
||||
|
||||
@ -36,6 +38,11 @@ inline fun Logger.debug(tag: String, message: String, e: Throwable? = null) = lo
|
||||
|
||||
// ----- Short names
|
||||
|
||||
|
||||
inline fun Logger.l(level: LogLevel, tag: String? = null, e: Throwable? = null, messageBuilder: () -> String) = log(level, tag, e, messageBuilder)
|
||||
inline fun Logger.l(level: LogLevel, message: String, e: Throwable? = null) = log(level, message, e)
|
||||
inline fun Logger.l(level: LogLevel, tag: String, message: String, e: Throwable? = null) = log(level, tag, message, e)
|
||||
|
||||
inline fun Logger.v(tag: String? = null, e: Throwable? = null, messageBuilder: () -> String) = verbose(tag, e, messageBuilder)
|
||||
inline fun Logger.v(message: String, e: Throwable? = null) = verbose(message, e)
|
||||
inline fun Logger.v(tag: String, message: String, e: Throwable? = null) = verbose(tag, message, e)
|
||||
|
@ -11,10 +11,10 @@ enum class LogLevel {
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
fun log (level: LogLevel, message: String, tag: String? = null, throwable: Throwable? = null)
|
||||
operator fun invoke(level: LogLevel, tag: String?, message: String, throwable: Throwable?)
|
||||
companion object : Logger {
|
||||
var DEFAULT: Logger = Logger("app")
|
||||
override fun log(level: LogLevel, message: String, tag: String?, throwable: Throwable?) = DEFAULT.log(level, message, tag, throwable)
|
||||
override fun invoke(level: LogLevel, tag: String?, message: String, throwable: Throwable?) = DEFAULT(level, tag, message, throwable)
|
||||
|
||||
operator fun invoke (log: (level: LogLevel, message: String, tag: String?, throwable: Throwable?) -> Unit) = CallbackLogger(log)
|
||||
}
|
||||
@ -23,7 +23,7 @@ interface Logger {
|
||||
class CallbackLogger(
|
||||
private val logger: (level: LogLevel, message: String, tag: String?, throwable: Throwable?) -> Unit
|
||||
) : Logger {
|
||||
override fun log(level: LogLevel, message: String, tag: String?, throwable: Throwable?) = logger(level, message, tag, throwable)
|
||||
override fun invoke(level: LogLevel, tag: String?, message: String, throwable: Throwable?) = logger(level, message, tag, throwable)
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user