Skip to content

Commit 4688242

Browse files
authored
Merge pull request #1841 from ahoppen/log-int-bool-public
Log integers and booleans as public information by default in `NonDarwinLogger`
2 parents 51634d8 + ea6f06f commit 4688242

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Sources/SKLogging/NonDarwinLogging.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ package struct NonDarwinLogInterpolation: StringInterpolationProtocol, Sendable
222222
append(description: String(reflecting: type), redactedDescription: "<private>", privacy: privacy)
223223
}
224224

225+
package mutating func appendInterpolation(
226+
_ message: some Numeric & Sendable,
227+
privacy: NonDarwinLogPrivacy = .public
228+
) {
229+
append(description: String(describing: message), redactedDescription: "<private>", privacy: privacy)
230+
}
231+
232+
package mutating func appendInterpolation(_ message: Bool, privacy: NonDarwinLogPrivacy = .public) {
233+
append(description: message.description, redactedDescription: "<private>", privacy: privacy)
234+
}
235+
225236
/// Builds the string that represents the log message, masking all interpolation
226237
/// segments whose privacy level is greater that `logPrivacyLevel`.
227238
fileprivate func string(for logPrivacyLevel: NonDarwinLogPrivacy) -> String {

Tests/SKLoggingTests/LoggingTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,22 @@ final class LoggingTests: XCTestCase {
212212
$0.log("got \(LogStringConvertible().forLogging)")
213213
}
214214
}
215+
216+
func testIntegerNotConsideredPrivate() async {
217+
await assertLogging(
218+
privacyLevel: .public,
219+
expected: ["got 42"]
220+
) {
221+
$0.log("got \(42)")
222+
}
223+
}
224+
225+
func testBoolNotConsideredPrivate() async {
226+
await assertLogging(
227+
privacyLevel: .public,
228+
expected: ["got true"]
229+
) {
230+
$0.log("got \(true)")
231+
}
232+
}
215233
}

0 commit comments

Comments
 (0)