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,13 +4,14 @@
import ExampleImplementation
import Foundation
import Logging
@testable import Logging // need access to internal bootstrap function
enum ConfigExample {
static func main() {
// boostrap with our config based sample implementations
let config = Config(defaultLogLevel: .info)
LoggingSystem.bootstrap({ ConfigLogHandler(label: $0, config: config) })
LoggingSystem.bootstrapInternal({ ConfigLogHandler(label: $0, config: config) })
// run the example
let logger = Logger(label: "com.example.TestApp")
logger.trace("hello world?")