From 242064744ed1bd766ebdc630075d7dda65afd5f8 Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Mon, 18 Aug 2025 10:03:39 +0200 Subject: [PATCH 1/5] instantiate logger directly --- CHANGELOG.md | 4 ++++ Sources/PowerSync/Kotlin/DatabaseLogger.swift | 21 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ce15e..20ec1d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +* [Internal] Instantiate Kotlin Kermit logger directly. + ## 1.4.0 * Added the ability to log PowerSync sync network requests. diff --git a/Sources/PowerSync/Kotlin/DatabaseLogger.swift b/Sources/PowerSync/Kotlin/DatabaseLogger.swift index 141bf2d..852dc07 100644 --- a/Sources/PowerSync/Kotlin/DatabaseLogger.swift +++ b/Sources/PowerSync/Kotlin/DatabaseLogger.swift @@ -40,13 +40,23 @@ private class KermitLogWriterAdapter: Kermit_coreLogWriter { } } +class KotlinKermitLoggerConfig: PowerSyncKotlin.Kermit_coreLoggerConfig { + var logWriterList: [Kermit_coreLogWriter] + var minSeverity: PowerSyncKotlin.Kermit_coreSeverity + + init(logWriterList: [Kermit_coreLogWriter], minSeverity: PowerSyncKotlin.Kermit_coreSeverity) { + self.logWriterList = logWriterList + self.minSeverity = minSeverity + } +} + /// A logger implementation that integrates with PowerSync's Kotlin core using Kermit. /// /// This class bridges Swift log writers with the Kotlin logging system and supports /// runtime configuration of severity levels and writer lists. class DatabaseLogger: LoggerProtocol { /// The underlying Kermit logger instance provided by the PowerSyncKotlin SDK. - public let kLogger = PowerSyncKotlin.generateLogger(logger: nil) + public let kLogger: PowerSyncKotlin.KermitLogger public let logger: any LoggerProtocol /// Initializes a new logger with an optional list of writers. @@ -55,9 +65,12 @@ class DatabaseLogger: LoggerProtocol { init(_ logger: any LoggerProtocol) { self.logger = logger // Set to the lowest severity. The provided logger should filter by severity - kLogger.mutableConfig.setMinSeverity(Kermit_coreSeverity.verbose) - kLogger.mutableConfig.setLogWriterList( - [KermitLogWriterAdapter(logger: logger)] + self.kLogger = PowerSyncKotlin.KermitLogger( + config: KotlinKermitLoggerConfig( + logWriterList: [KermitLogWriterAdapter(logger: logger)], + minSeverity: Kermit_coreSeverity.verbose + ), + tag: "PowerSync" ) } From 5807b0c4f337938ce0640248eb9149dc5ebaba3a Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Mon, 18 Aug 2025 11:04:00 +0200 Subject: [PATCH 2/5] update xcode action --- .github/workflows/build_and_test.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index eb4caa9..0928449 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -10,6 +10,11 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 + - name: Set up XCode + if: runner.os == 'macOS' + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable - name: Build and Test run: | xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 15" From 6c8d882c1629d7c62a399fc440bb9e62b616ec44 Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Mon, 18 Aug 2025 12:30:46 +0200 Subject: [PATCH 3/5] update device name --- .github/workflows/build_and_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index 0928449..64fd7af 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -17,6 +17,6 @@ jobs: xcode-version: latest-stable - name: Build and Test run: | - xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 15" + xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 16" xcodebuild test -scheme PowerSync -destination "platform=macOS,arch=arm64,name=My Mac" xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64" From 4bb21a881b23027ea14136b85cba157559c9267b Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Mon, 18 Aug 2025 13:43:37 +0200 Subject: [PATCH 4/5] update watch tests --- .github/workflows/build_and_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index 64fd7af..b29de8c 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -19,4 +19,4 @@ jobs: run: | xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 16" xcodebuild test -scheme PowerSync -destination "platform=macOS,arch=arm64,name=My Mac" - xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64" + xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64name=Apple Watch Ultra 2" From 2915f8239e0a94f855b5caa95c9416264d8c82d2 Mon Sep 17 00:00:00 2001 From: stevensJourney Date: Wed, 20 Aug 2025 09:29:06 +0200 Subject: [PATCH 5/5] fix typo. remove macos check --- .github/workflows/build_and_test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index b29de8c..6b1bbbd 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -11,7 +11,6 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up XCode - if: runner.os == 'macOS' uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: latest-stable @@ -19,4 +18,4 @@ jobs: run: | xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 16" xcodebuild test -scheme PowerSync -destination "platform=macOS,arch=arm64,name=My Mac" - xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64name=Apple Watch Ultra 2" + xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64,name=Apple Watch Ultra 2 (49mm)"