From 82085783c05b495f092a1c815667d926b041a132 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 8 Jun 2022 12:59:41 +0600 Subject: [PATCH] fix of #3 --- src/commonMain/kotlin/AutoLoggers.kt | 6 ++---- src/commonMain/kotlin/TagLogger.kt | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/commonMain/kotlin/TagLogger.kt diff --git a/src/commonMain/kotlin/AutoLoggers.kt b/src/commonMain/kotlin/AutoLoggers.kt index 042013e..e1803e7 100644 --- a/src/commonMain/kotlin/AutoLoggers.kt +++ b/src/commonMain/kotlin/AutoLoggers.kt @@ -2,7 +2,5 @@ package dev.inmo.kslog.common val Any.logTag get() = this::class.simpleName ?: error("Unable to retrieve log tag") -val Any.logger - get() = CallbackKSLog { l, t, m, e -> - KSLog.default.performLog(l, t ?: logTag, m, e) - } +val Any.logger: KSLog + get() = TagLogger(logTag) diff --git a/src/commonMain/kotlin/TagLogger.kt b/src/commonMain/kotlin/TagLogger.kt new file mode 100644 index 0000000..7fe1286 --- /dev/null +++ b/src/commonMain/kotlin/TagLogger.kt @@ -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) + } +}