refactor examples and remove dependecy on foundation

motivation:
* due to the low level nature of the library we prefer not to force-load foundation
* help reviewers diffrentiate between examples of usage vs implementation, and add more realistic usage and implementations examples

changes:
* remove foundation from Logging module, replace with c based locks and time functions
* rewrite usage examples to be more realistic
* add example of an implementation that writes to files
* add example of an implementation that is config driven
* rename warn -> warning
This commit is contained in:
tomer doron committed 2019-01-05 02:03:44 -08:00
1 parent 0f23cda751
commit 9027df5f03
25 files changed
+858 -381

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
//
// THIS IS NOT PART OF THE PITCH, JUST AN EXAMPLE HOW A LOGGER USAGE LOOKS LIKE
//
import Foundation
import Logging
// this is a contrived example of a 3rd party library that is used by the other examples
// this library does not know anything about the systewm that used it, so cannot make
// assumptions about them
class RandomLibrary {
private let logger = Logging.make("RandomLibrary")
private let queue = DispatchQueue(label: "RandomLibrary")
public init() {}
public func doSomething() {
self.logger.info("doSomething")
}
public func doSomethingAsync(completion: @escaping () -> Void) {
self.queue.asyncAfter(deadline: .now() + 0.1) {
self.logger.info("doSomethingAsync")
completion()
}
}
}