Files
swift-log/Tests/LoggingTests/LoggingTest.swift
T
tomer doron 9027df5f03 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
2019-01-05 02:03:44 -08:00

22 lines
902 B
Swift

@testable import Logging
import XCTest
class LoggingTest: XCTestCase {
func testMUX() throws {
// bootstrap with our test logging impl
let logging1 = TestLogging()
let logging2 = TestLogging()
Logging.bootstrap(MultiplexLogging([logging1.make, logging2.make]).make)
var logger = Logging.make("test")
logger.logLevel = .warning
logger.info("hello world")
logger[metadataKey: "foo"] = "bar"
logger.warning("hello world!")
logging1.history.assertNotExist(level: .info, metadata: nil, message: "hello world")
logging2.history.assertNotExist(level: .info, metadata: nil, message: "hello world")
logging1.history.assertExist(level: .warning, metadata: ["foo": "bar"], message: "hello world!")
logging2.history.assertExist(level: .warning, metadata: ["foo": "bar"], message: "hello world!")
}
}