I'm wondering how I'm supposed to handle the following fairly common scenario using Unified Logging. Let's say I have an object of class Foo which I want to log. Foo implements the CustomStringConvertible protocol, so I can get a description of the object I can use in my logs:
class Foo: CustomStringConvertible {
var bar:Int = 1
var description: String {
return "<\(type(of: self)): bar = \(bar)>"
}
}
let myFoo = Foo()
If I call print(myFoo)
, I get a nice description of Foo. However, os_log(myFoo)
won't work since description is not a StaticString. Is there a way to accomplish what I'm trying to do?