Repository navigation
Conversation
pfandrade
force-pushed
the
feature/swift-log
branch
from
March 19, 2026 15:11
f3ab6b3 to
820cf64
Compare
# Conflicts: # Package.resolved # Package.swift # Sources/SQLiteData/CloudKit/SyncEngine.swift # Tests/SQLiteDataTests/Internal/BaseCloudKitTests.swift
pfandrade
force-pushed
the
feature/swift-log
branch
from
September 30, 2026 09:51
0a5f875 to
924969a
Compare
stephencelis
approved these changes
Nov 4, 2026
stephencelis
left a comment
Member
There was a problem hiding this comment.
Thanks for opening this! A trait seems like a good way to manage things. Just a few to-dos:
Comment on lines
+4
to
+5
| @_exported import struct Logging.Logger | ||
| import protocol Logging.LogHandler |
Member
There was a problem hiding this comment.
Do we need to export or qualify these imports? Can we simply do:
Suggested change
| @_exported import struct Logging.Logger | |
| import protocol Logging.LogHandler | |
| public import Logging |
| #endif | ||
|
|
||
| #if SQLiteDataSwiftLog | ||
| struct DisabledLogHandler: Logging.LogHandler { |
Member
There was a problem hiding this comment.
This can be private/fileprivate, right?
Suggested change
| struct DisabledLogHandler: Logging.LogHandler { | |
| private struct DisabledLogHandler: Logging.LogHandler { |
| delegate: (any SyncEngineDelegate)? = nil, | ||
| logger: Logger = isTesting | ||
| ? Logger(.disabled) : Logger(subsystem: "SQLiteData", category: "CloudKit") | ||
| logger: Logger = isTesting ? Logger.disabled : Logger.default |
Member
There was a problem hiding this comment.
Can this be abbreviated?
Suggested change
| logger: Logger = isTesting ? Logger.disabled : Logger.default | |
| logger: Logger = isTesting ? .disabled : .default |
| description: "Introduce SQLiteData conformances to the swift-tagged package." | ||
| ), | ||
| .trait( | ||
| name: "SQLiteDataSwiftLog", |
Member
There was a problem hiding this comment.
SPM has converged on a simpler naming convention here:
Suggested change
| name: "SQLiteDataSwiftLog", | |
| name: "SwiftLog", |
| .product( | ||
| name: "Logging", | ||
| package: "swift-log", | ||
| condition: .when(traits: ["SQLiteDataSwiftLog"]) |
Member
There was a problem hiding this comment.
Suggested change
| condition: .when(traits: ["SQLiteDataSwiftLog"]) | |
| condition: .when(traits: ["SwiftLog"]) |
| #if DEBUG && canImport(CloudKit) | ||
| #if canImport(CloudKit) | ||
|
|
||
| #if SQLiteDataSwiftLog |
Member
There was a problem hiding this comment.
Suggested change
| #if SQLiteDataSwiftLog | |
| #if SwiftLog |
| } | ||
| #endif | ||
|
|
||
| #if SQLiteDataSwiftLog |
Member
There was a problem hiding this comment.
Suggested change
| #if SQLiteDataSwiftLog | |
| #if SwiftLog |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per discussion #293, this PR adds support for using swift-log for
SyncEnginelogs.More precisely it adds a new
SQLiteDataSwiftLogtrait that allows for conditionally using swift-log instead of OSLog (which remains the default). Since theLoggerAPI of both solutions is essentially the same, very little code needed to change.Main changes are on
Logging.swift, where the check forSQLiteDataSwiftLogis performed, and a typealiasSyncEngine.Loggeris defined.One decision I made that I'm not quite sure about is using
@_exportedinLogging.swiftto export the rightLoggertype. Doing this avoids having to do the#if SQLiteDataSwiftLogdance to import either swift-log or OSLog in any file that uses it1.Footnotes
I believe, currently, just
SyncEngine.swiftwould need to this import dance. But if logging is needed anywhere else, or if that file gets split up, we'd have to replicate the dance. ↩