enforce that logging system can only be bootstrapped once (#32)

motivation: safer logging system

changes: do a precondition check to verify logging syste is only initialized/bootstrapped once per process
This commit is contained in:
tomer doron authored and Johannes Weiss committed 2019-02-22 18:13:52 +00:00
1 parent 045ba36718
commit c7583429a6
11 files changed
+47 -26

No files matched your search

+3 -2
View File
@@ -4,12 +4,13 @@
import ExampleImplementation
import Foundation
import Logging
@testable import Logging // need access to internal bootstrap function
enum MultiplexExample {
static func main() {
// boostrap with two of our sample implementations
LoggingSystem.bootstrap({ MultiplexLogHandler([SimpleLogHandler(label: $0), FileLogHandler(label: $0)]) })
LoggingSystem.bootstrapInternal({ MultiplexLogHandler([SimpleLogHandler(label: $0), FileLogHandler(label: $0)]) })
// run the example
let logger = Logger(label: "com.example.TestApp")
logger.info("hello world!")