From 588877cb20fbc3dc4fea252b2ab2e8a23dba08d6 Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 12 Jul 2020 18:17:04 +0200 Subject: [PATCH] Removed CachedLoggerFactory as Kotlin/Native cannot cope with shared state of loggerCache Map --- .../multiplatform/log/CachedLoggerFactory.kt | 24 ------------------- .../log/LogToConsoleLoggerFactory.kt | 4 ++-- .../multiplatform/log/Slf4jLoggerFactory.kt | 4 ++-- 3 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/CachedLoggerFactory.kt diff --git a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/CachedLoggerFactory.kt b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/CachedLoggerFactory.kt deleted file mode 100644 index 8d41021e..00000000 --- a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/CachedLoggerFactory.kt +++ /dev/null @@ -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() // 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 - } - -} \ No newline at end of file diff --git a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LogToConsoleLoggerFactory.kt b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LogToConsoleLoggerFactory.kt index 20788519..b71ee4c2 100644 --- a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LogToConsoleLoggerFactory.kt +++ b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LogToConsoleLoggerFactory.kt @@ -1,9 +1,9 @@ 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) } diff --git a/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLoggerFactory.kt b/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLoggerFactory.kt index c4c94cb7..b8814c98 100644 --- a/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLoggerFactory.kt +++ b/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLoggerFactory.kt @@ -3,9 +3,9 @@ package net.dankito.utils.multiplatform.log 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)) }