mirror of
https://github.com/InsanusMokrassar/KSLog.git
synced 2024-11-18 06:03:47 +00:00
commit
de56994cf7
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 0.0.2
|
||||
|
||||
* New logger `TagLogger` and now extension `Any#logger` will use it to decrease objects allocations
|
||||
* Now it is possible to create `KSLog` using any iterable
|
||||
* Now it is possible to create `KSLog` using vararg log levels
|
||||
|
||||
## 0.0.1
|
||||
|
||||
* Project has been inited
|
||||
|
@ -9,5 +9,5 @@ android.enableJetifier=true
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.0.1
|
||||
android_code_version=1
|
||||
version=0.0.2
|
||||
android_code_version=2
|
||||
|
@ -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)
|
||||
|
@ -44,11 +44,21 @@ expect fun KSLog(
|
||||
|
||||
fun KSLog(
|
||||
defaultTag: String,
|
||||
levels: Set<LogLevel>
|
||||
): KSLog = KSLog (defaultTag) { l, _, _, _ ->
|
||||
l in levels
|
||||
levels: Iterable<LogLevel>
|
||||
): KSLog {
|
||||
val levels = levels.toSet()
|
||||
return KSLog (defaultTag) { l, _, _, _ ->
|
||||
l in levels
|
||||
}
|
||||
}
|
||||
|
||||
inline fun KSLog(
|
||||
defaultTag: String,
|
||||
firstLevel: LogLevel,
|
||||
secondLevel: LogLevel,
|
||||
vararg otherLevels: LogLevel
|
||||
): KSLog = KSLog(defaultTag, setOf(firstLevel, secondLevel, *otherLevels))
|
||||
|
||||
fun KSLog(
|
||||
defaultTag: String,
|
||||
minLoggingLevel: LogLevel = LogLevel.VERBOSE
|
||||
|
10
src/commonMain/kotlin/TagLogger.kt
Normal file
10
src/commonMain/kotlin/TagLogger.kt
Normal 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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user