in TwitterLoggingServiceTests/TLSLoggingSwiftTests.swift [184:219]
func testSwiftLogging() {
let context = Date()
setExpectationForLoggingLevel(.error)
TLSLog.error("TestChannel", "Message with context: \(context)")
waitForExpectations(timeout: 10)
setExpectationForLoggingLevel(.warning)
TLSLog.warning("TestChannel", "Message with context: \(context)")
waitForExpectations(timeout: 10)
setExpectationForLoggingLevel(.information)
TLSLog.information("TestChannel", "Message with context: \(context)")
waitForExpectations(timeout: 10)
setExpectationForLoggingLevel(.alert)
TLSLog.log(.alert, "TestChannel", context, "Message with context: \(context)")
waitForExpectations(timeout: 10)
#if DEBUG
setExpectationForLoggingLevel(.debug)
TLSLog.debug("TestChannel", "Message with context: \(context)") // documentation explicitly states this only logs to debug builds
waitForExpectations(timeout: 10)
#endif
var delayedDate = Date()
func delayedEvaluation() -> String {
delayedDate = Date()
return delayedDate.description
}
Thread.sleep(forTimeInterval: 0.000001)
let dateBeforeLog = Date()
XCTAssert(delayedDate < dateBeforeLog)
TLSLog.information("TestChannel", delayedEvaluation())
XCTAssert(dateBeforeLog < delayedDate)
}