Default reduction of interpolated nonnumeric values doesn't work

I'm experimenting with the (relatively) new Logger API after watching WWDC20 session "Explore logging in Swift", and I don't see a default reduction of the values that was discussed in the talk.

When I run this code,

let i = A(a: "aaaa", b: 111)
logger.error("Password: \(i)") // privacy: .auto
logger.error("Password: \(i, privacy: .public)")
logger.error("Password: \(i, privacy: .private)")
logger.error("Password: \(i, privacy: .private(mask: .none))")
logger.error("Password: \(i, privacy: .private(mask: .hash))")

I get this output in both Xcode console and Console.app:

2023-08-20 22:55:57.373918+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.373988+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.374014+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.374032+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111
2023-08-20 22:55:57.374055+0300 MyApp[75828:757479] [MyCategory] Password: a: aaaa, b: 111

My assumption is that when running the code from Xcode with debug build configuration the system generously opens up any private values so I can inspect them conveniently. But when I ran my code with the release config, I got the same output. However, I want to test what data will be stored on my users' devices when I write different privacy options

Any ideas why this happens?

Replies

My assumption is that when running the code from Xcode with debug build configuration the system generously opens up any private values so I can inspect them conveniently.

It’s not based on your build configuration but on how you run the app. If you want to confirm that private entries don’t make it to the log, run your app from the Home screen, using Console app to monitor them.

ps I have lots of logging hints and tips in Your Friend the System Log.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"