address #2: provide an example logging a String (#3)

- fixes #2
This commit is contained in:
Johannes Weiss authored and GitHub committed 2019-03-05 19:44:46 +00:00
1 parent 7dd7738627
commit 78b84e39ff
1 file changed
+16
+16
View File
@@ -270,4 +270,20 @@ class LoggingTest: XCTestCase {
testLogging.history.assertExist(level: .debug,
message: "My favourite number is \(someInt) and not \(someInt - 1)" as String)
}
func testLoggingAString() {
let testLogging = TestLogging()
LoggingSystem.bootstrapInternal(testLogging.make)
var logger = Logger(label: "\(#function)")
logger.logLevel = .debug
let anActualString: String = "hello world!"
// We can't stick an actual String in here because we expect a Logger.Message. If we want to log an existing
// `String`, we can use string interpolation. The error you'll get trying to use the String directly is:
//
// error: Cannot convert value of type 'String' to expected argument type 'Logger.Message'
logger.debug("\(anActualString)")
testLogging.history.assertExist(level: .debug, message: "hello world!")
}
}