Skip to content

Commit b906368

Browse files
update naming in protocols
1 parent caeb66c commit b906368

File tree

6 files changed

+37
-36
lines changed

6 files changed

+37
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## 1.4.0
44

5-
* Added the ability to log PowerSync network requests.
5+
* Added the ability to log PowerSync sync network requests.
6+
67
```swift
7-
struct InlineLogger: NetworkLogger {
8+
struct InlineLogger: SyncRequestLogger {
89
func log(_ message: String) {
910
print("Network: \(message)")
1011
}
@@ -14,7 +15,7 @@ try await db.connect(
1415
connector: connector,
1516
options: ConnectOptions(
1617
clientConfiguration: SyncClientConfiguration(
17-
networkLogger: NetworkLoggerConfig(
18+
requestLogger: SyncRequestLoggerConfiguration(
1819
logLevel: .headers,
1920
logger: InlineLogger()
2021
)

Sources/PowerSync/Kotlin/KotlinNetworkLogger.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import PowerSyncKotlin
22

3-
extension NetworkLogLevel {
4-
func toKotlin() -> SwiftNetworkLogLevel {
3+
extension SyncRequestLogLevel {
4+
func toKotlin() -> SwiftSyncRequestLogLevel {
55
switch self {
66
case .all:
7-
return SwiftNetworkLogLevel.all
7+
return SwiftSyncRequestLogLevel.all
88
case .headers:
9-
return SwiftNetworkLogLevel.headers
9+
return SwiftSyncRequestLogLevel.headers
1010
case .body:
11-
return SwiftNetworkLogLevel.body
11+
return SwiftSyncRequestLogLevel.body
1212
case .info:
13-
return SwiftNetworkLogLevel.info
13+
return SwiftSyncRequestLogLevel.info
1414
case .none:
15-
return SwiftNetworkLogLevel.none
15+
return SwiftSyncRequestLogLevel.none
1616
}
1717
}
1818
}
1919

20-
extension NetworkLoggerConfig {
21-
func toKotlinConfig() -> SwiftNetworkLoggerConfig {
22-
return SwiftNetworkLoggerConfig(
20+
extension SyncRequestLoggerConfiguration {
21+
func toKotlinConfig() -> SwiftRequestLoggerConfig {
22+
return SwiftRequestLoggerConfig(
2323
logLevel: self.logLevel.toKotlin(),
2424
log: { [logger] message in
2525
logger.log(message)

Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol {
6161
options: createSyncOptions(
6262
newClient: resolvedOptions.newClientImplementation,
6363
userAgent: "PowerSync Swift SDK",
64-
loggingConfig: resolvedOptions.clientConfiguration?.networkLogger?.toKotlinConfig()
64+
loggingConfig: resolvedOptions.clientConfiguration?.requestLogger?.toKotlinConfig()
6565
)
6666
)
6767
}

Sources/PowerSync/Protocol/PowerSyncDatabaseProtocol.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ public struct SyncClientConfiguration {
88
/// Optional configuration for logging PowerSync HTTP requests.
99
///
1010
/// When provided, network requests will be logged according to the
11-
/// specified `NetworkLogLevel`. The `logLevel` is set during initialization
11+
/// specified `SyncRequestLogLevel`. The `logLevel` is set during initialization
1212
/// and remains constant throughout the PowerSync session.
1313
///
14-
/// Set to `nil` to disable network logging entirely.
14+
/// Set to `nil` to disable request logging entirely.
1515
///
16-
/// - SeeAlso: `NetworkLoggerConfig` for configuration options
17-
public let networkLogger: NetworkLoggerConfig?
16+
/// - SeeAlso: `SyncRequestLoggerConfiguration` for configuration options
17+
public let requestLogger: SyncRequestLoggerConfiguration?
1818

1919
/// Creates a new sync client configuration.
20-
/// - Parameter networkLogger: Optional network logger configuration
21-
public init(networkLogger: NetworkLoggerConfig? = nil) {
22-
self.networkLogger = networkLogger
20+
/// - Parameter requestLogger: Optional network logger configuration
21+
public init(requestLogger: SyncRequestLoggerConfiguration? = nil) {
22+
self.requestLogger = requestLogger
2323
}
2424
}
2525

Sources/PowerSync/Protocol/NetworkLogger.swift renamed to Sources/PowerSync/Protocol/SyncRequestLogger.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/// A logger which handles PowerSync network request logs.
22
///
3-
/// Implement this protocol to receive network logging messages at the level
4-
/// specified in `NetworkLoggerConfig`. The `log(_:)` method will be called
3+
/// Implement this protocol to receive network request logging messages at the level
4+
/// specified in `SyncRequestLoggerConfiguration`. The `log(_:)` method will be called
55
/// for each network event that meets the configured logging criteria.
6-
public protocol NetworkLogger {
6+
public protocol SyncRequestLogger {
77
/// Logs a network-related message.
88
/// - Parameter message: The formatted log message to record
99
func log(_ message: String)
1010
}
1111

12-
/// Level of logs to expose to a `NetworkLogger` handler.
12+
/// Level of logs to expose to a `SyncRequestLogger` handler.
1313
///
1414
/// Controls the verbosity of network logging for PowerSync HTTP requests.
1515
/// The log level is configured once during initialization and determines
1616
/// which network events will be logged throughout the session.
17-
public enum NetworkLogLevel {
17+
public enum SyncRequestLogLevel {
1818
/// Log all network activity including headers, body, and info
1919
case all
2020
/// Log only request/response headers
@@ -34,20 +34,20 @@ public enum NetworkLogLevel {
3434
/// are logged, while the `logger` handles the actual log output.
3535
///
3636
/// - Note: The log level cannot be changed after initialization. A new call to `PowerSyncDatabase.connect` is required to change the level.
37-
public struct NetworkLoggerConfig {
37+
public struct SyncRequestLoggerConfiguration {
3838
/// The logging level that determines which network events are logged.
3939
/// Set once during initialization and used throughout the session.
40-
public let logLevel: NetworkLogLevel
40+
public let logLevel: SyncRequestLogLevel
4141

42-
/// The logger instance that receives network log messages.
43-
/// Must conform to `NetworkLogger` protocol.
44-
public let logger: NetworkLogger
42+
/// The logger instance that receives network request log messages.
43+
/// Must conform to `SyncRequestLogger` protocol.
44+
public let logger: SyncRequestLogger
4545

4646
/// Creates a new network logger configuration.
4747
/// - Parameters:
48-
/// - logLevel: The `NetworkLogLevel` to use for filtering log messages
49-
/// - logger: A `NetworkLogger` instance to handle log output
50-
public init(logLevel: NetworkLogLevel, logger: NetworkLogger) {
48+
/// - logLevel: The `SyncRequestLogLevel` to use for filtering log messages
49+
/// - logger: A `SyncRequestLogger` instance to handle log output
50+
public init(logLevel: SyncRequestLogLevel, logger: SyncRequestLogger) {
5151
self.logLevel = logLevel
5252
self.logger = logger
5353
}

Tests/PowerSyncTests/ConnectTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ final class ConnectTests: XCTestCase {
9696

9797
let fakeUrl = "https://fakepowersyncinstance.fakepowersync.local"
9898

99-
struct InlineLogger: NetworkLogger {
99+
struct InlineLogger: SyncRequestLogger {
100100
let logger: (_: String) -> Void
101101

102102
func log(_ message: String) {
@@ -130,7 +130,7 @@ final class ConnectTests: XCTestCase {
130130
connector: TestConnector(url: fakeUrl),
131131
options: ConnectOptions(
132132
clientConfiguration: SyncClientConfiguration(
133-
networkLogger: NetworkLoggerConfig(
133+
requestLogger: SyncRequestLoggerConfiguration(
134134
logLevel:
135135
.all,
136136
logger: testLogger

0 commit comments

Comments
 (0)