Skip to content

Commit f28111a

Browse files
[Internal] Logger Updates (#67)
* instantiate logger directly * update xcode action * update device name * update watch tests * fix typo. remove macos check
1 parent 0be5ca2 commit f28111a

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

.github/workflows/build_and_test.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ jobs:
1010
runs-on: macos-latest
1111
steps:
1212
- uses: actions/checkout@v4
13+
- name: Set up XCode
14+
uses: maxim-lobanov/setup-xcode@v1
15+
with:
16+
xcode-version: latest-stable
1317
- name: Build and Test
1418
run: |
15-
xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 15"
19+
xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 16"
1620
xcodebuild test -scheme PowerSync -destination "platform=macOS,arch=arm64,name=My Mac"
17-
xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64"
21+
xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64,name=Apple Watch Ultra 2 (49mm)"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
* [Internal] Instantiate Kotlin Kermit logger directly.
6+
37
## 1.4.0
48

59
* Added the ability to log PowerSync sync network requests.

Sources/PowerSync/Kotlin/DatabaseLogger.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,23 @@ private class KermitLogWriterAdapter: Kermit_coreLogWriter {
4040
}
4141
}
4242

43+
class KotlinKermitLoggerConfig: PowerSyncKotlin.Kermit_coreLoggerConfig {
44+
var logWriterList: [Kermit_coreLogWriter]
45+
var minSeverity: PowerSyncKotlin.Kermit_coreSeverity
46+
47+
init(logWriterList: [Kermit_coreLogWriter], minSeverity: PowerSyncKotlin.Kermit_coreSeverity) {
48+
self.logWriterList = logWriterList
49+
self.minSeverity = minSeverity
50+
}
51+
}
52+
4353
/// A logger implementation that integrates with PowerSync's Kotlin core using Kermit.
4454
///
4555
/// This class bridges Swift log writers with the Kotlin logging system and supports
4656
/// runtime configuration of severity levels and writer lists.
4757
class DatabaseLogger: LoggerProtocol {
4858
/// The underlying Kermit logger instance provided by the PowerSyncKotlin SDK.
49-
public let kLogger = PowerSyncKotlin.generateLogger(logger: nil)
59+
public let kLogger: PowerSyncKotlin.KermitLogger
5060
public let logger: any LoggerProtocol
5161

5262
/// Initializes a new logger with an optional list of writers.
@@ -55,9 +65,12 @@ class DatabaseLogger: LoggerProtocol {
5565
init(_ logger: any LoggerProtocol) {
5666
self.logger = logger
5767
// Set to the lowest severity. The provided logger should filter by severity
58-
kLogger.mutableConfig.setMinSeverity(Kermit_coreSeverity.verbose)
59-
kLogger.mutableConfig.setLogWriterList(
60-
[KermitLogWriterAdapter(logger: logger)]
68+
self.kLogger = PowerSyncKotlin.KermitLogger(
69+
config: KotlinKermitLoggerConfig(
70+
logWriterList: [KermitLogWriterAdapter(logger: logger)],
71+
minSeverity: Kermit_coreSeverity.verbose
72+
),
73+
tag: "PowerSync"
6174
)
6275
}
6376

0 commit comments

Comments
 (0)