From 5083acc032c66bf243b5750f3197eab18a3e9cfe Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 11 Jul 2020 12:19:50 +0200 Subject: [PATCH] Implemented NSLogLogger and NSLogLoggerFactory --- .../utils/multiplatform/log/NSLogLogger.kt | 19 +++++++++++++++++++ .../multiplatform/log/NSLogLoggerFactory.kt | 10 ++++++++++ 2 files changed, 29 insertions(+) create mode 100644 common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLogger.kt create mode 100644 common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLoggerFactory.kt diff --git a/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLogger.kt b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLogger.kt new file mode 100644 index 00000000..21ea843f --- /dev/null +++ b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLogger.kt @@ -0,0 +1,19 @@ +package net.dankito.utils.multiplatform.log + +import net.dankito.utils.multiplatform.Date +import net.dankito.utils.multiplatform.DateFormatter +import platform.Foundation.NSLog + + +open class NSLogLogger(name: String) : LoggerBase(name) { + + companion object { + private val DateFormatter = DateFormatter("HH:mm:ss.SSS") + } + + + override fun log(level: LogLevel, message: String) { + NSLog("${DateFormatter.format(Date())} $level $name - $message") + } + +} \ No newline at end of file diff --git a/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLoggerFactory.kt b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLoggerFactory.kt new file mode 100644 index 00000000..81a82704 --- /dev/null +++ b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/log/NSLogLoggerFactory.kt @@ -0,0 +1,10 @@ +package net.dankito.utils.multiplatform.log + + +open class NSLogLoggerFactory : ILoggerFactory { + + override fun getLogger(name: String): Logger { + return NSLogLogger(name) + } + +} \ No newline at end of file