WIP: logging utilities

This commit is contained in:
John Rommel Estropia
2016-05-05 09:44:14 +08:00
parent 099dcfab68
commit 0073d038e0
46 changed files with 791 additions and 396 deletions

View File

@@ -110,7 +110,7 @@ public extension CSBaseDataTransaction {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
"Attempted to fetch from a \(typeName(self)) outside its designated queue."
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.bridgeToSwift.context.fetchOne(from, fetchClauses)
}
@@ -128,7 +128,7 @@ public extension CSBaseDataTransaction {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
"Attempted to fetch from a \(typeName(self)) outside its designated queue."
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.bridgeToSwift.context.fetchAll(from, fetchClauses)
}
@@ -146,7 +146,7 @@ public extension CSBaseDataTransaction {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
"Attempted to fetch from a \(typeName(self)) outside its designated queue."
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.bridgeToSwift.context.fetchCount(from, fetchClauses)
}
@@ -164,7 +164,7 @@ public extension CSBaseDataTransaction {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
"Attempted to fetch from a \(typeName(self)) outside its designated queue."
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.bridgeToSwift.context.fetchObjectID(from, fetchClauses)
}
@@ -185,7 +185,7 @@ public extension CSBaseDataTransaction {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
"Attempted to query from a \(typeName(self)) outside its designated queue."
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.bridgeToSwift.context.queryValue(from, selectClause, queryClauses)
}
@@ -206,7 +206,7 @@ public extension CSBaseDataTransaction {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
"Attempted to query from a \(typeName(self)) outside its designated queue."
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.bridgeToSwift.context.queryAttributes(from, selectClause, queryClauses)
}

View File

@@ -47,12 +47,10 @@ public extension CSCoreStore {
- parameter storage: the `CSInMemoryStore` instance
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
*/
public static func addInMemoryStorage(storage: CSInMemoryStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> NSProgress? {
public static func addInMemoryStorage(storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
return self.defaultStack.addInMemoryStorage(storage, completion: completion, error: error)
self.defaultStack.addInMemoryStorage(storage, completion: completion)
}
/**

View File

@@ -47,19 +47,14 @@ public extension CSDataStack {
- parameter storage: the `CSInMemoryStore` instance
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
*/
@objc
public func addInMemoryStorage(storage: CSInMemoryStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> NSProgress? {
public func addInMemoryStorage(storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
return bridge(error) {
try self.bridgeToSwift.addStorage(
storage.bridgeToSwift,
completion: { completion($0.bridgeToObjectiveC) }
)
}
self.bridgeToSwift.addStorage(
storage.bridgeToSwift,
completion: { completion($0.bridgeToObjectiveC) }
)
}
/**

View File

@@ -61,7 +61,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to observe objects from \(typeName(self)) outside the main thread."
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
CoreStore.assert(
fetchClauses.contains { $0 is CSOrderBy },
@@ -93,7 +93,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to observe objects from \(typeName(self)) outside the main thread."
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
CoreStore.assert(
fetchClauses.contains { $0 is CSOrderBy },
@@ -128,7 +128,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to observe objects from \(typeName(self)) outside the main thread."
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
CoreStore.assert(
fetchClauses.contains { $0 is CSOrderBy },
@@ -160,7 +160,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to observe objects from \(typeName(self)) outside the main thread."
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
CoreStore.assert(
fetchClauses.contains { $0 is CSOrderBy },

View File

@@ -110,7 +110,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to fetch from a \(typeName(self)) outside the main thread."
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchOne(from, fetchClauses)
}
@@ -128,7 +128,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to fetch from a \(typeName(self)) outside the main thread."
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchAll(from, fetchClauses)
}
@@ -146,7 +146,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to fetch from a \(typeName(self)) outside the main thread."
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchCount(from, fetchClauses)
}
@@ -164,7 +164,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to fetch from a \(typeName(self)) outside the main thread."
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchObjectID(from, fetchClauses)
}
@@ -182,7 +182,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to fetch from a \(typeName(self)) outside the main thread."
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchObjectIDs(from, fetchClauses)
}
@@ -203,7 +203,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to query from a \(typeName(self)) outside the main thread."
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.queryValue(from, selectClause, queryClauses)
}
@@ -224,7 +224,7 @@ public extension CSDataStack {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to query from a \(typeName(self)) outside the main thread."
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.queryAttributes(from, selectClause, queryClauses)
}