OSLogPrivacy: what's the difference between .private and .sensitive?

Viewed 181

I'm in the process of implementing logging in my app using the new os.log API's from iOS 14 / macOS 11.

I've just noticed that we have more choice when it comes to the privacy of the included variables in our logs. There are the classic public and private, but there's also auto and sensitive. The documentation for the sensitive case says that "this option behaves identically to the private option". So why should we use it and what are its benefits?

Logger.auth.log(level: .debug, "Signed request \(String(describing: request.url), privacy: .sensitive)")

(Logger.auth is an extension on Logger in my project which just declares a new static logger object. See this blog post for more informations.)

1 Answers

The only benefit I can guess is to allow multiple "channels" for the developer. You can choose to use private for user details and sensitive for internal identifiers/ secret details.

This would allow you to choose to always redact sensitive values, but only sometimes redact private values. However, it's up to you.

Related