OSLogPrivacy.auto clarification please

Am I right that .auto is just the default privacy specifier for when an explicit one is not mentioned in the log code, and as such there is no need to ever use it explicitly?

Code Block swift
var i =123
var s = "hello"
myLogger.log("\(s, privacy: .auto), \(i, privacy: .auto)")

produces the same log as:
Code Block swift
myLogger.log("\(s), \(i)")

and that s ==> "<private>" in the logs and i ==> 123

Also in:
Code Block swift
myLogger.log("\(s, privacy: .auto(mask: .hash)), \(i, privacy: .auto(mask: .hash))")

that only s will be hashed as i resolves to being public so no masking is needed and 123 is displayed.

(The documentation could really use some actual examples of more use cases)

Answered by DTS Engineer in 671203022

Am I right that .auto is just the default privacy specifier for when
an explicit one is not mentioned in the log code, and as such there is
no need to ever use it explicitly?

Yes.

If you option click on each of the privacy identifiers in line 3 of your snippet, Xcode’s displays this:

Code Block
mutating func appendInterpolation(_ argumentString: @autoclosure @escaping () -> String, align: OSLogStringAlignment = .none, privacy: OSLogPrivacy = .auto)


and this:

Code Block
mutating func appendInterpolation(_ number: @autoclosure @escaping () -> Int, format: OSLogIntegerFormatting = .decimal, align: OSLogStringAlignment = .none, privacy: OSLogPrivacy = .auto)


As you can see, the privacy argument has a default value of .auto.

(The documentation could really use some actual examples of more use
cases)

The best way to get that feedback to the folks who maintain the documentation is to file a bug against it. Please post your bug number, just for the record.

Share and Enjoy

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

Am I right that .auto is just the default privacy specifier for when
an explicit one is not mentioned in the log code, and as such there is
no need to ever use it explicitly?

Yes.

If you option click on each of the privacy identifiers in line 3 of your snippet, Xcode’s displays this:

Code Block
mutating func appendInterpolation(_ argumentString: @autoclosure @escaping () -> String, align: OSLogStringAlignment = .none, privacy: OSLogPrivacy = .auto)


and this:

Code Block
mutating func appendInterpolation(_ number: @autoclosure @escaping () -> Int, format: OSLogIntegerFormatting = .decimal, align: OSLogStringAlignment = .none, privacy: OSLogPrivacy = .auto)


As you can see, the privacy argument has a default value of .auto.

(The documentation could really use some actual examples of more use
cases)

The best way to get that feedback to the folks who maintain the documentation is to file a bug against it. Please post your bug number, just for the record.

Share and Enjoy

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