This commit is contained in:
InsanusMokrassar 2022-06-08 12:59:41 +06:00
parent 5f49b183e0
commit 82085783c0
2 changed files with 12 additions and 4 deletions

View File

@ -2,7 +2,5 @@ package dev.inmo.kslog.common
val Any.logTag val Any.logTag
get() = this::class.simpleName ?: error("Unable to retrieve log tag") get() = this::class.simpleName ?: error("Unable to retrieve log tag")
val Any.logger val Any.logger: KSLog
get() = CallbackKSLog { l, t, m, e -> get() = TagLogger(logTag)
KSLog.default.performLog(l, t ?: logTag, m, e)
}

View File

@ -0,0 +1,10 @@
package dev.inmo.kslog.common
import kotlin.jvm.JvmInline
@JvmInline
value class TagLogger(val tag: String) : KSLog {
override fun performLog(level: LogLevel, tag: String?, message: String, throwable: Throwable?) {
KSLog.performLog(level, tag ?: tag, message, throwable)
}
}