From 30b0c78ea74862cc566ab27eb0d3b487775bac84 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Fri, 15 Nov 2024 11:51:10 -0500 Subject: [PATCH] OSLogWriter takes optional subsystem and category (#409) Resolves #393 Co-authored-by: Kevin Schildhorn --- .../kotlin/co/touchlab/kermit/OSLogWriter.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/OSLogWriter.kt b/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/OSLogWriter.kt index a5306f7f..6512c386 100644 --- a/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/OSLogWriter.kt +++ b/kermit-core/src/appleMain/kotlin/co/touchlab/kermit/OSLogWriter.kt @@ -27,12 +27,12 @@ import kotlin.experimental.ExperimentalNativeApi */ open class OSLogWriter internal constructor( private val messageStringFormatter: MessageStringFormatter, - private val darwinLogger: DarwinLogger + private val darwinLogger: DarwinLogger, ) : LogWriter() { - constructor(messageStringFormatter: MessageStringFormatter = DefaultFormatter) : this( + constructor(messageStringFormatter: MessageStringFormatter = DefaultFormatter, subsystem: String = "", category: String = "") : this( messageStringFormatter, - DarwinLoggerActual + DarwinLoggerActual(subsystem, category), ) override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { @@ -77,9 +77,9 @@ internal interface DarwinLogger { } @OptIn(ExperimentalForeignApi::class) -private object DarwinLoggerActual : DarwinLogger { - private val logger = darwin_log_create("", "")!! +private class DarwinLoggerActual(subsystem: String, category: String) : DarwinLogger { + private val logger = darwin_log_create(subsystem, category)!! override fun log(osLogSeverity: os_log_type_t, message: String) { darwin_log_with_type(logger, osLogSeverity, message) } -} \ No newline at end of file +}