I was working on Logging on to iOS and decided to learn more about Logger structure in iOS, started with Apple Official Documentation which is quite well, and after watched WWDC 2020 video about Logging, the problem is that I could not achieve to simulate the private logging as the documentation dictate or even in WWDC video did, somehow my application couldn't achieve it. I already examine the logs from the XCode terminal and the Console app with Simulator + Real Device, let me share my piece of code on logging.
let logger = Logger(subsystem: "com.myname.LogExample", category: "ViewController")
let appName = "LogExample"
let numberToBePrivate = 35
logger.notice("Hello, this is default message")
logger.notice("Hello again, this is default message with private integer of \(numberToBePrivate, privacy: .private)")
logger.log("Hello, my name is \(appName, privacy: .private)")
And my logs, the outputs of the XCode terminal
202开发者_开发知识库2-12-07 01:30:14.372319+0200 LogExample[62053:2356742] [ViewController] Hello, this is default message
2022-12-07 01:30:14.372816+0200 LogExample[62053:2356742] [ViewController] Hello again, this is default message with private integer of 35
2022-12-07 01:30:14.372921+0200 LogExample[62053:2356742] [ViewController] Hello, my name is LogExample
And in the Console app
What I expect is a total <private>
mark on the message of set private privacy sections, which is the expected one.
As I know, the output in the Console.app for the second log should be exact like this:
Hello again, this is default message with private integer of <private>
As I said before, I tried both the simulator + real device and the behavior of the Logger is totally the same. If I am doing anything wrong, I would like to learn it or any idea which useful would be super cool.
PS: notice
and log
function is the same level, notice
basically is the default log level, and when you don't describe the level in the log
function, it is described as default
, so they are basically the same. And they are supposed be persisted.
Thanks
精彩评论