2929
3030public import Foundation
3131public import MistKit
32+ public import BushelLogging
3233
3334/// Orchestrates the complete sync process from data sources to CloudKit
3435///
@@ -79,33 +80,32 @@ public struct SyncEngine: Sendable {
7980 /// Execute full sync from all data sources to CloudKit
8081 public func sync( options: SyncOptions = SyncOptions ( ) ) async throws -> SyncResult {
8182 print ( " \n " + String( repeating: " = " , count: 60 ) )
82- BushelLogger . info ( " 🔄 Starting Bushel CloudKit Sync" , subsystem : BushelLogger . sync )
83+ ConsoleOutput . info ( " Starting Bushel CloudKit Sync " )
8384 print ( String ( repeating: " = " , count: 60 ) )
85+ Self . logger. info ( " Sync started " )
8486
8587 if options. dryRun {
86- BushelLogger . info (
87- " 🧪 DRY RUN MODE - No changes will be made to CloudKit " , subsystem : BushelLogger . sync )
88+ ConsoleOutput . info ( " DRY RUN MODE - No changes will be made to CloudKit " )
89+ Self . logger . info ( " Sync running in dry-run mode " )
8890 }
8991
90- BushelLogger . explain (
91- " This sync demonstrates MistKit's Server-to-Server authentication and bulk record operations " ,
92- subsystem: BushelLogger . sync
92+ Self . logger. debug (
93+ " Using MistKit Server-to-Server authentication for bulk record operations "
9394 )
9495
9596 // Step 1: Fetch from all data sources
9697 print ( " \n 📥 Step 1: Fetching data from external sources... " )
97- BushelLogger . verbose (
98- " Initializing data source pipeline to fetch from ipsw.me, TheAppleWiki, MESU, and other sources " ,
99- subsystem : BushelLogger . dataSource )
98+ Self . logger . debug (
99+ " Initializing data source pipeline to fetch from ipsw.me, TheAppleWiki, MESU, and other sources "
100+ )
100101
101102 let fetchResult = try await pipeline. fetch ( options: options. pipelineOptions)
102103
103- BushelLogger . verbose (
104- " Data fetch complete. Beginning deduplication and merge phase. " ,
105- subsystem: BushelLogger . dataSource)
106- BushelLogger . explain (
107- " Multiple data sources may have overlapping data. The pipeline deduplicates by version+build number. " ,
108- subsystem: BushelLogger . dataSource
104+ Self . logger. debug (
105+ " Data fetch complete. Beginning deduplication and merge phase. "
106+ )
107+ Self . logger. debug (
108+ " Multiple data sources may have overlapping data. The pipeline deduplicates by version+build number. "
109109 )
110110
111111 let stats = SyncResult (
@@ -124,18 +124,18 @@ public struct SyncEngine: Sendable {
124124 print ( " ───────────────────── " )
125125 print ( " Total: \( totalRecords) records " )
126126
127- BushelLogger . verbose (
128- " Records ready for CloudKit upload: \( totalRecords) total " , subsystem: BushelLogger . sync)
127+ Self . logger. debug (
128+ " Records ready for CloudKit upload: \( totalRecords) total "
129+ )
129130
130131 // Step 2: Sync to CloudKit (unless dry run)
131132 if !options. dryRun {
132133 print ( " \n ☁️ Step 2: Syncing to CloudKit... " )
133- BushelLogger . verbose (
134- " Using MistKit to batch upload records to CloudKit public database " ,
135- subsystem: BushelLogger . cloudKit)
136- BushelLogger . explain (
137- " MistKit handles authentication, batching (200 records/request), and error handling automatically " ,
138- subsystem: BushelLogger . cloudKit
134+ Self . logger. debug (
135+ " Using MistKit to batch upload records to CloudKit public database "
136+ )
137+ Self . logger. debug (
138+ " MistKit handles authentication, batching (200 records/request), and error handling automatically "
139139 )
140140
141141 // Sync in dependency order: SwiftVersion → RestoreImage → XcodeVersion
@@ -151,73 +151,79 @@ public struct SyncEngine: Sendable {
151151 print ( " • \( stats. restoreImagesCount) restore images " )
152152 print ( " • \( stats. xcodeVersionsCount) Xcode versions " )
153153 print ( " • \( stats. swiftVersionsCount) Swift versions " )
154- BushelLogger . verbose (
155- " Dry run mode: No CloudKit operations performed " , subsystem: BushelLogger . sync)
154+ Self . logger. debug (
155+ " Dry run mode: No CloudKit operations performed "
156+ )
156157 }
157158
158159 print ( " \n " + String( repeating: " = " , count: 60 ) )
159- BushelLogger . success ( " Sync completed successfully! " , subsystem : BushelLogger . sync )
160+ ConsoleOutput . success ( " Sync completed successfully! " )
160161 print ( String ( repeating: " = " , count: 60 ) )
162+ Self . logger. info ( " Sync completed successfully " )
161163
162164 return stats
163165 }
164166
165167 /// Delete all records from CloudKit
166168 public func clear( ) async throws {
167169 print ( " \n " + String( repeating: " = " , count: 60 ) )
168- BushelLogger . info ( " 🗑️ Clearing all CloudKit data" , subsystem : BushelLogger . cloudKit )
170+ ConsoleOutput . info ( " Clearing all CloudKit data " )
169171 print ( String ( repeating: " = " , count: 60 ) )
172+ Self . logger. info ( " Clearing all CloudKit records " )
170173
171174 try await cloudKitService. deleteAllRecords ( )
172175
173176 print ( " \n " + String( repeating: " = " , count: 60 ) )
174- BushelLogger . success ( " Clear completed successfully! " , subsystem : BushelLogger . sync )
177+ ConsoleOutput . success ( " Clear completed successfully! " )
175178 print ( String ( repeating: " = " , count: 60 ) )
179+ Self . logger. info ( " Clear completed successfully " )
176180 }
177181
178182 /// Export all records from CloudKit to a structured format
179183 public func export( ) async throws -> ExportResult {
180184 print ( " \n " + String( repeating: " = " , count: 60 ) )
181- BushelLogger . info ( " 📤 Exporting data from CloudKit" , subsystem : BushelLogger . cloudKit )
185+ ConsoleOutput . info ( " Exporting data from CloudKit " )
182186 print ( String ( repeating: " = " , count: 60 ) )
187+ Self . logger. info ( " Exporting CloudKit data " )
183188
184- BushelLogger . explain (
185- " Using MistKit's queryRecords() to fetch all records of each type from the public database " ,
186- subsystem: BushelLogger . cloudKit
189+ Self . logger. debug (
190+ " Using MistKit queryRecords() to fetch all records of each type from the public database "
187191 )
188192
189193 print ( " \n 📥 Fetching RestoreImage records... " )
190- BushelLogger . verbose (
191- " Querying CloudKit for recordType: 'RestoreImage' with limit: 1000 " ,
192- subsystem : BushelLogger . cloudKit )
194+ Self . logger . debug (
195+ " Querying CloudKit for recordType: 'RestoreImage' with limit: 1000 "
196+ )
193197 let restoreImages = try await cloudKitService. queryRecords ( recordType: " RestoreImage " )
194- BushelLogger . verbose (
195- " Retrieved \( restoreImages. count) RestoreImage records " , subsystem: BushelLogger . cloudKit)
198+ Self . logger. debug (
199+ " Retrieved \( restoreImages. count) RestoreImage records "
200+ )
196201
197202 print ( " 📥 Fetching XcodeVersion records... " )
198- BushelLogger . verbose (
199- " Querying CloudKit for recordType: 'XcodeVersion' with limit: 1000 " ,
200- subsystem : BushelLogger . cloudKit )
203+ Self . logger . debug (
204+ " Querying CloudKit for recordType: 'XcodeVersion' with limit: 1000 "
205+ )
201206 let xcodeVersions = try await cloudKitService. queryRecords ( recordType: " XcodeVersion " )
202- BushelLogger . verbose (
203- " Retrieved \( xcodeVersions. count) XcodeVersion records " , subsystem: BushelLogger . cloudKit)
207+ Self . logger. debug (
208+ " Retrieved \( xcodeVersions. count) XcodeVersion records "
209+ )
204210
205211 print ( " 📥 Fetching SwiftVersion records... " )
206- BushelLogger . verbose (
207- " Querying CloudKit for recordType: 'SwiftVersion' with limit: 1000 " ,
208- subsystem : BushelLogger . cloudKit )
212+ Self . logger . debug (
213+ " Querying CloudKit for recordType: 'SwiftVersion' with limit: 1000 "
214+ )
209215 let swiftVersions = try await cloudKitService. queryRecords ( recordType: " SwiftVersion " )
210- BushelLogger . verbose (
211- " Retrieved \( swiftVersions. count) SwiftVersion records " , subsystem: BushelLogger . cloudKit)
216+ Self . logger. debug (
217+ " Retrieved \( swiftVersions. count) SwiftVersion records "
218+ )
212219
213220 print ( " \n ✅ Exported: " )
214221 print ( " • \( restoreImages. count) restore images " )
215222 print ( " • \( xcodeVersions. count) Xcode versions " )
216223 print ( " • \( swiftVersions. count) Swift versions " )
217224
218- BushelLogger . explain (
219- " MistKit returns RecordInfo structs with record metadata. Use .fields to access CloudKit field values. " ,
220- subsystem: BushelLogger . cloudKit
225+ Self . logger. debug (
226+ " MistKit returns RecordInfo structs with record metadata. Use .fields to access CloudKit field values. "
221227 )
222228
223229 return ExportResult (
@@ -255,3 +261,8 @@ public struct SyncEngine: Sendable {
255261 }
256262 }
257263}
264+
265+ // MARK: - Loggable Conformance
266+ extension SyncEngine : Loggable {
267+ public static let loggingCategory : BushelLogging . Category = . application
268+ }
0 commit comments