Given the following two lines, XCode is showing an error for the second line saying Cannot convert value of type 'String' to expected argument type 'OSLogMessage'.
logger.info("Device found:")
logger.info(String(describing: device))
Can someone please explain why this error is shown? In both cases, the parameter is of type String. (I guess)
Currently, I fix this by using string interpolation. But this does not feel right. Is there a better way than:
logger.info("\(String(describing: device))")
The (surprising, perhaps) answer is that OSLog doesn't allow an arbitrary string to be logged for privacy reasons. It's not a language limitation but a policy to control the availability of user data in logs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With