mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 10:21:40 +01:00
WIP: logging utilities
This commit is contained in:
@@ -64,7 +64,7 @@ public final class DataStack {
|
||||
|
||||
CoreStore.assert(
|
||||
migrationChain.valid,
|
||||
"Invalid migration chain passed to the \(typeName(DataStack)). Check that the model versions' order is correct and that no repetitions or ambiguities exist."
|
||||
"Invalid migration chain passed to the \(cs_typeName(DataStack)). Check that the model versions' order is correct and that no repetitions or ambiguities exist."
|
||||
)
|
||||
|
||||
self.coordinator = NSPersistentStoreCoordinator(managedObjectModel: model)
|
||||
@@ -174,7 +174,7 @@ public final class DataStack {
|
||||
let storeError = CoreStoreError(error)
|
||||
CoreStore.log(
|
||||
storeError,
|
||||
"Failed to add \(typeName(storage)) to the stack."
|
||||
"Failed to add \(cs_typeName(storage)) to the stack."
|
||||
)
|
||||
throw storeError
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public final class DataStack {
|
||||
let fileURL = storage.fileURL
|
||||
CoreStore.assert(
|
||||
fileURL.fileURL,
|
||||
"The specified store URL for the \"\(typeName(storage))\" is invalid: \"\(fileURL)\""
|
||||
"The specified store URL for the \"\(cs_typeName(storage))\" is invalid: \"\(fileURL)\""
|
||||
)
|
||||
|
||||
if let _ = self.persistentStoreForStorage(storage) {
|
||||
@@ -231,7 +231,7 @@ public final class DataStack {
|
||||
let error = CoreStoreError.DifferentStorageExistsAtURL(existingPersistentStoreURL: fileURL)
|
||||
CoreStore.log(
|
||||
error,
|
||||
"Failed to add \(typeName(storage)) at \"\(fileURL)\" because a different \(typeName(NSPersistentStore)) at that URL already exists."
|
||||
"Failed to add \(cs_typeName(storage)) at \"\(fileURL)\" because a different \(cs_typeName(NSPersistentStore)) at that URL already exists."
|
||||
)
|
||||
throw error
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public final class DataStack {
|
||||
let storeError = CoreStoreError(error)
|
||||
CoreStore.log(
|
||||
storeError,
|
||||
"Failed to add \(typeName(storage)) to the stack."
|
||||
"Failed to add \(cs_typeName(storage)) to the stack."
|
||||
)
|
||||
throw storeError
|
||||
}
|
||||
@@ -325,7 +325,7 @@ public final class DataStack {
|
||||
let error = CoreStoreError.DifferentStorageExistsAtURL(existingPersistentStoreURL: cacheFileURL)
|
||||
CoreStore.log(
|
||||
error,
|
||||
"Failed to add \(typeName(storage)) at \"\(cacheFileURL)\" because a different \(typeName(NSPersistentStore)) at that URL already exists."
|
||||
"Failed to add \(cs_typeName(storage)) at \"\(cacheFileURL)\" because a different \(cs_typeName(NSPersistentStore)) at that URL already exists."
|
||||
)
|
||||
throw error
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public final class DataStack {
|
||||
let storeError = CoreStoreError(error)
|
||||
CoreStore.log(
|
||||
storeError,
|
||||
"Failed to add \(typeName(storage)) to the stack."
|
||||
"Failed to add \(cs_typeName(storage)) to the stack."
|
||||
)
|
||||
throw storeError
|
||||
}
|
||||
@@ -489,7 +489,7 @@ public final class DataStack {
|
||||
let managedObjectClassName = entityDescription.managedObjectClassName
|
||||
CoreStore.assert(
|
||||
NSClassFromString(managedObjectClassName) != nil,
|
||||
"The class \(typeName(managedObjectClassName)) for the entity \(typeName(entityDescription.name)) does not exist. Check if the subclass type and module name are properly configured."
|
||||
"The class \(cs_typeName(managedObjectClassName)) for the entity \(cs_typeName(entityDescription.name)) does not exist. Check if the subclass type and module name are properly configured."
|
||||
)
|
||||
|
||||
if self.entityConfigurationsMapping[managedObjectClassName] == nil {
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
"Attempted to add an observer of type \(typeName(observer)) outside the main thread."
|
||||
"Attempted to add an observer of type \(cs_typeName(observer)) outside the main thread."
|
||||
)
|
||||
|
||||
self.removeObserver(observer)
|
||||
@@ -196,45 +196,45 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
"Attempted to remove an observer of type \(typeName(observer)) outside the main thread."
|
||||
"Attempted to remove an observer of type \(cs_typeName(observer)) outside the main thread."
|
||||
)
|
||||
let nilValue: AnyObject? = nil
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.willFinishInitialImportKey,
|
||||
inObject: observer
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.didFinishInitialImportKey,
|
||||
inObject: observer
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.willAddAccountKey,
|
||||
inObject: observer
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.didAddAccountKey,
|
||||
inObject: observer
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.willRemoveAccountKey,
|
||||
inObject: observer
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.didRemoveAccountKey,
|
||||
inObject: observer
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.willRemoveContentKey,
|
||||
inObject: observer
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &self.didRemoveContentKey,
|
||||
inObject: observer
|
||||
@@ -272,7 +272,7 @@ public class ICloudStore: CloudStorage {
|
||||
self.dataStack = dataStack
|
||||
let coordinator = dataStack.coordinator
|
||||
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
NotificationObserver(
|
||||
notificationName: NSPersistentStoreCoordinatorStoresWillChangeNotification,
|
||||
object: coordinator,
|
||||
@@ -314,7 +314,7 @@ public class ICloudStore: CloudStorage {
|
||||
forKey: &Static.persistentStoreCoordinatorWillChangeStores,
|
||||
inObject: self
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
NotificationObserver(
|
||||
notificationName: NSPersistentStoreCoordinatorStoresDidChangeNotification,
|
||||
object: coordinator,
|
||||
@@ -365,12 +365,12 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
let coordinator = dataStack.coordinator
|
||||
let nilValue: AnyObject? = nil
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &Static.persistentStoreCoordinatorWillChangeStores,
|
||||
inObject: coordinator
|
||||
)
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
nilValue,
|
||||
forKey: &Static.persistentStoreCoordinatorDidChangeStores,
|
||||
inObject: coordinator
|
||||
@@ -423,7 +423,7 @@ public class ICloudStore: CloudStorage {
|
||||
// TODO: check if attached to persistent store
|
||||
|
||||
let cacheFileURL = self.cacheFileURL
|
||||
try autoreleasepool {
|
||||
try cs_autoreleasepool {
|
||||
|
||||
let journalUpdatingCoordinator = NSPersistentStoreCoordinator(managedObjectModel: soureModel)
|
||||
let options = [
|
||||
@@ -467,7 +467,7 @@ public class ICloudStore: CloudStorage {
|
||||
|
||||
private func registerNotification<T: ICloudStoreObserver>(notificationKey: UnsafePointer<Void>, name: String, toObserver observer: T, callback: (observer: T, storage: ICloudStore, dataStack: DataStack) -> Void) {
|
||||
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
NotificationObserver(
|
||||
notificationName: name,
|
||||
object: self,
|
||||
|
||||
@@ -105,14 +105,18 @@ public protocol ICloudStoreObserver: class {
|
||||
public extension ICloudStoreObserver {
|
||||
|
||||
public func iCloudStoreWillFinishUbiquitousStoreInitialImport(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
|
||||
public func iCloudStoreDidFinishUbiquitousStoreInitialImport(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
|
||||
public func iCloudStoreWillAddAccount(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
|
||||
public func iCloudStoreDidAddAccount(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
|
||||
public func iCloudStoreWillRemoveAccount(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
|
||||
public func iCloudStoreDidRemoveAccount(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
|
||||
public func iCloudStoreWillRemoveContent(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
|
||||
public func iCloudStoreDidRemoveContent(storage storage: ICloudStore, dataStack: DataStack) {}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
// TODO: check if attached to persistent store
|
||||
|
||||
let fileURL = self.fileURL
|
||||
try autoreleasepool {
|
||||
try cs_autoreleasepool {
|
||||
|
||||
let journalUpdatingCoordinator = NSPersistentStoreCoordinator(managedObjectModel: soureModel)
|
||||
let store = try journalUpdatingCoordinator.addPersistentStoreWithType(
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
|
||||
// TODO: check if attached to persistent store
|
||||
|
||||
let fileURL = self.fileURL
|
||||
try autoreleasepool {
|
||||
try cs_autoreleasepool {
|
||||
|
||||
let journalUpdatingCoordinator = NSPersistentStoreCoordinator(managedObjectModel: soureModel)
|
||||
let store = try journalUpdatingCoordinator.addPersistentStoreWithType(
|
||||
|
||||
Reference in New Issue
Block a user