mirror of
https://github.com/UrbanApps/Armchair.git
synced 2026-04-20 16:01:26 +02:00
Merge pull request #35 from phimage/feature-capturelog
Allow to capture log using closure
This commit is contained in:
@@ -563,6 +563,18 @@ public func shouldIncrementUseCountClosure(shouldIncrementUseCountClosure: Armch
|
||||
Manager.defaultManager.shouldIncrementUseCountClosure = shouldIncrementUseCountClosure
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: Armchair Logger Protocol
|
||||
public typealias ArmchairLogger = (Manager, log: String, file: StaticString, function: StaticString, line: UInt) -> Void
|
||||
|
||||
/*
|
||||
* Set a closure to capture debug log and to plug in the desired logging framework.
|
||||
*/
|
||||
public func logger(logger: ArmchairLogger) {
|
||||
Manager.defaultManager.logger = logger
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Armchair Defaults Protocol
|
||||
|
||||
@@ -1717,11 +1729,15 @@ public class Manager : ArmchairManager {
|
||||
|
||||
let lockQueue = dispatch_queue_create("com.armchair.lockqueue", nil)
|
||||
|
||||
private func debugLog(log: String) {
|
||||
if debugEnabled {
|
||||
dispatch_sync(lockQueue, {
|
||||
public var logger: ArmchairLogger = { manager, log, file, function, line in
|
||||
if manager.debugEnabled {
|
||||
dispatch_sync(manager.lockQueue, {
|
||||
print("[Armchair] \(log)")
|
||||
})
|
||||
}
|
||||
}
|
||||
private func debugLog(log: String, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__) {
|
||||
logger(self, log: log, file: file, function: function, line: line)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user