mirror of
https://github.com/apple/swift-log
synced 2026-11-25 03:57:48 +00:00
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
22 lines
902 B
Swift
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!")
|
|
}
|
|
}
|