Adding support for logging via swift-log #324
Open
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. ↩