Removed CachedLoggerFactory as Kotlin/Native cannot cope with shared state of loggerCache Map

This commit is contained in:
dankito 2020-07-12 18:17:04 +02:00
parent 79a3080bbd
commit 588877cb20
3 changed files with 4 additions and 28 deletions

View File

@ -1,24 +0,0 @@
package net.dankito.utils.multiplatform.log
abstract class CachedLoggerFactory : ILoggerFactory {
abstract fun createLogger(name: String): Logger
protected open val loggerCache = mutableMapOf<String, Logger>() // TODO: make thread safe like with ConcurrentHashMap
override fun getLogger(name: String): Logger {
loggerCache[name]?.let {
return it
}
val logger = createLogger(name)
loggerCache[name] = logger
return logger
}
}

View File

@ -1,9 +1,9 @@
package net.dankito.utils.multiplatform.log package net.dankito.utils.multiplatform.log
open class LogToConsoleLoggerFactory : CachedLoggerFactory() { open class LogToConsoleLoggerFactory : ILoggerFactory {
override fun createLogger(name: String): Logger { override fun getLogger(name: String): Logger {
return ConsoleLogger(name) return ConsoleLogger(name)
} }

View File

@ -3,9 +3,9 @@ package net.dankito.utils.multiplatform.log
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
open class Slf4jLoggerFactory : CachedLoggerFactory() { open class Slf4jLoggerFactory : ILoggerFactory {
override fun createLogger(name: String): Logger { override fun getLogger(name: String): Logger {
return Slf4jLogger(LoggerFactory.getLogger(name)) return Slf4jLogger(LoggerFactory.getLogger(name))
} }