From d53f61a76fef03ec48cdd3af04b260b0a478a672 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sat, 23 May 2026 15:21:39 -0700 Subject: [PATCH] fix(swift-diagnostics): T5.2 \u2014 replace print() with os.Logger OSDiagnosticsLogger was using print() for actual log output despite being the 'OSLog-based logger' implementation. Per AGENTS.md and the existing struct name, it should use os.Logger. Changes: + import os + private let logger: Logger (initialised in init()) + logger.debug / info / warning / error replace print() at all 4 sites + uses privacy: .public to make messages visible in Console.app scripts/check-rule-violations.sh shows 4 \u2192 0 swift-print findings in this package. The common-plat repo now contributes 0 swift-print to the ecosystem total. --- .../Core/Configuration.swift | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/swift-diagnostics/Sources/ByteLystDiagnostics/Core/Configuration.swift b/packages/swift-diagnostics/Sources/ByteLystDiagnostics/Core/Configuration.swift index 2f7ef6a8..1b8bdcff 100644 --- a/packages/swift-diagnostics/Sources/ByteLystDiagnostics/Core/Configuration.swift +++ b/packages/swift-diagnostics/Sources/ByteLystDiagnostics/Core/Configuration.swift @@ -1,4 +1,5 @@ import Foundation +import os /// Client configuration public struct DiagnosticsConfiguration: Sendable { @@ -77,27 +78,29 @@ public struct NoOpDiagnosticsLogger: DiagnosticsLogger { public struct OSDiagnosticsLogger: DiagnosticsLogger { private let subsystem: String private let category: String - + private let logger: Logger + public init(subsystem: String = "com.bytelyst.diagnostics", category: String = "DiagnosticsClient") { self.subsystem = subsystem self.category = category + self.logger = Logger(subsystem: subsystem, category: category) } - + public func debug(_ message: String, metadata: [String: any Sendable]?) { #if DEBUG - print("[DEBUG] \(message)") + logger.debug("\(message, privacy: .public)") #endif } - + public func info(_ message: String, metadata: [String: any Sendable]?) { - print("[INFO] \(message)") + logger.info("\(message, privacy: .public)") } - + public func warn(_ message: String, metadata: [String: any Sendable]?) { - print("[WARN] \(message)") + logger.warning("\(message, privacy: .public)") } - + public func error(_ message: String, metadata: [String: any Sendable]?) { - print("[ERROR] \(message)") + logger.error("\(message, privacy: .public)") } }