When exporting OSLog entries from OSLogStore, composedMessage doesn't seem to respect the given privacy marker. This feels like a bug to me, but it maybe a case of me holding it wrong.
Here's an example:
import UIKit
import OSLog
class ViewController: UIViewController {
let logger = Logger(subsystem: "com.example.project", category: "ViewController")
override func viewDidLoad() {
super.viewDidLoad()
logger.info("Top secret number \(42, privacy: .private)")
do {
let store = try OSLogStore(scope: .currentProcessIdentifier)
let postion = store.position(timeIntervalSinceLatestBoot: 1)
let logs = try store.getEntries(at: postion)
.compactMap { $0 as? OSLogEntryLog }
.filter { $0.subsystem == "com.example.project" }
.map { $0.composedMessage }
// Prints:
// Logger: ["Top secret number 42"]
print("Logger: \(logs)")
} catch {
print(error)
}
}
}
Is there a more appropriate way to format the text ready for sharing?