os.Logger (os_log) ignores the new privacy string interpolation

Viewed 575

Using the following code on a iOS 14 simulator, all the log statements are printed in clear-text. There is no redactions or hashing happening. Both in the Xcode console, and in the Console.app on Mac.

Is anything else required to test if the redaction work?

let email = "apple@stackoverflow.com"
let logger = Logger()
logger.log("\(email, privacy: .auto)")
logger.log("\(email, privacy: .auto(mask: .hash))")
logger.log("\(email, privacy: .private)")
logger.log("\(email, privacy: .private(mask: .hash))")
1 Answers

You are doing this with the simulator. It only applies when running on a physical device.

Also, the device must not be attached to the debugger.

E.g. here is the console when I watch it while connected to debugger:

enter image description here

When you run this code on a physical device while not connected to the debugger and watch on the macOS console, you will see:

enter image description here

Related