From 2281d1758d2de7c0cb56b49f96fff4a90469b6c0 Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 11 Jul 2020 12:20:38 +0200 Subject: [PATCH] Implemented DefaultLoggerFactory to create platform specific logger --- .../utils/multiplatform/log/DefaultLoggerFactory.kt | 8 ++++++++ .../dankito/utils/multiplatform/log/LoggerFactory.kt | 6 +++++- .../utils/multiplatform/log/DefaultLoggerFactory.kt | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt create mode 100644 common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt diff --git a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt new file mode 100644 index 00000000..1da22d9e --- /dev/null +++ b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt @@ -0,0 +1,8 @@ +package net.dankito.utils.multiplatform.log + + +expect class DefaultLoggerFactory() { + + fun createDefaultLoggerFactory(): ILoggerFactory + +} \ No newline at end of file diff --git a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LoggerFactory.kt b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LoggerFactory.kt index fdc2e5a7..58514a52 100644 --- a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LoggerFactory.kt +++ b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/log/LoggerFactory.kt @@ -7,7 +7,11 @@ class LoggerFactory { companion object { - var loggerFactory: ILoggerFactory = LogToConsoleLoggerFactory() + var loggerFactory: ILoggerFactory = createDefaultLoggerFactory() + + private fun createDefaultLoggerFactory(): ILoggerFactory { + return DefaultLoggerFactory().createDefaultLoggerFactory() + } fun getLogger(name: String): Logger { diff --git a/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt new file mode 100644 index 00000000..545207b8 --- /dev/null +++ b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/DefaultLoggerFactory.kt @@ -0,0 +1,10 @@ +package net.dankito.utils.multiplatform.log + + +actual class DefaultLoggerFactory { + + actual fun createDefaultLoggerFactory(): ILoggerFactory { + return NSLogLoggerFactory() + } + +} \ No newline at end of file