Last active
May 7, 2021 14:32
-
-
Save valeriomazzeo/bf7fe4b07059aa4c014b80bfd20bc017 to your computer and use it in GitHub Desktop.
SwiftyBeaver+ThreadSafe.swift related to https://github.com/SwiftyBeaver/SwiftyBeaver/issues/340
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Relates to https://github.com/SwiftyBeaver/SwiftyBeaver/issues/340 | |
*/ | |
extension SwiftyBeaver { | |
@usableFromInline | |
static let queue = DispatchQueue(label: "com.asensei.asensei.SwiftyBeaver") | |
@discardableResult | |
class func ts_addDestination(_ destination: BaseDestination) -> Bool { | |
return self.queue.sync { SwiftyBeaver.addDestination(destination) } | |
} | |
@discardableResult | |
class func ts_removeDestination(_ destination: BaseDestination) -> Bool { | |
return self.queue.sync { SwiftyBeaver.removeDestination(destination) } | |
} | |
class func ts_removeAllDestinations() { | |
self.queue.sync { SwiftyBeaver.removeAllDestinations() } | |
} | |
class func ts_countDestinations() -> Int { | |
return self.queue.sync { SwiftyBeaver.countDestinations() } | |
} | |
} | |
extension SwiftyBeaver: Logger { | |
public static func custom(level: LoggerLevel, message: @autoclosure () -> Any, file: String, function: String, line: Int, context: Any?) { | |
self.queue.sync { | |
SwiftyBeaver.custom( | |
level: .init(level), | |
message: message(), | |
file: file, | |
function: function, | |
line: line, | |
context: context | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment