jvmMain.UltraLogManager.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logging-jvm Show documentation
Show all versions of logging-jvm Show documentation
"Logging Tools For Kotlin"
package de.peekandpoke.ultra.logging
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import java.time.ZonedDateTime
import kotlin.reflect.KClass
class UltraLogManager(appenders: List) {
companion object {
private val scopeJob = SupervisorJob()
private val scope = CoroutineScope(Dispatchers.Unconfined + scopeJob)
}
private val appenders = appenders.toMutableList()
fun getLogger(cls: KClass<*>): Log {
return LogImpl(cls, this)
}
fun log(level: LogLevel, message: String, loggerName: String) {
val now = ZonedDateTime.now()
scope.launch {
appenders.forEach {
it.append(now, level, message, loggerName)
}
}
}
fun add(appender: LogAppender) {
appenders.add(appender)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy