Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
fix(logging): exclude verbose diagnostics from production builds
altic-dev0348e7141800
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex b4b29f60..8138f999 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -2577,8 +2577,7 @@ struct ContentView: View {private func processStoppedTranscription(route: DictationOutputRoute, pipelineID: String, toggleStopRequestedAt: TimeInterval?) async {let pipelineStartedAt = ProcessInfo.processInfo.systemUptimelet expectedOverlayLifecycleID = self.overlayLifecycleID- let loadAverageField = self.benchmarkLoadAverage()- self.appBench("pipeline_begin id=\(pipelineID) route=\(route.rawValue) toggleStopRequestedAt=\(toggleStopRequestedAt.map { String($0) } ?? "nil") loadAvg1m=\(loadAverageField)")+ self.appBench("pipeline_begin id=\(pipelineID) route=\(route.rawValue) toggleStopRequestedAt=\(toggleStopRequestedAt.map { String($0) } ?? "nil") loadAvg1m=\(self.benchmarkLoadAverage())")defer {self.appBench("pipeline_handler_return id=\(pipelineID) elapsedMs=\((ProcessInfo.processInfo.systemUptime - pipelineStartedAt) * 1000) deliveryMayBePending=true")}@@ -4777,8 +4776,8 @@ extension ContentView {return loadSampleCount > 0 ? String(format: "%.1f", loadAverages[0]) : "nil"}- private func appBench(_ message: String) {- DebugLogger.shared.benchmark("APP_BENCH", message: message, source: "AppBenchmark")+ private func appBench(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("APP_BENCH", message: message(), source: "AppBenchmark")}private func logAIProcessCall(diff --git a/Sources/Fluid/Persistence/TranscriptionHistoryDatabase.swift b/Sources/Fluid/Persistence/TranscriptionHistoryDatabase.swiftindex 8c4d7249..529513a1 100644--- a/Sources/Fluid/Persistence/TranscriptionHistoryDatabase.swift+++ b/Sources/Fluid/Persistence/TranscriptionHistoryDatabase.swift@@ -155,7 +155,7 @@ final class TranscriptionHistoryWriter: @unchecked Sendable {}.sorted { $0.timestamp > $1.timestamp }// The transaction is committed and every payload decoded before retiring legacy storage.self.defaults.removeObject(forKey: self.legacyKey)- DebugLogger.shared.info("HISTORY_BENCH loaded entries=\(entries.count) storage=sqlite", source: "TranscriptionHistoryStore")+ DebugLogger.shared.debug("HISTORY_BENCH loaded entries=\(entries.count) storage=sqlite", source: "TranscriptionHistoryStore")continuation.resume(returning: entries)} catch {continuation.resume(throwing: error)@@ -178,7 +178,7 @@ final class TranscriptionHistoryWriter: @unchecked Sendable {try database.write(upserts: records, deletes: deletes, replacing: replacing)if replacing { self.writeError = nil }let finishedAt = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info(+ DebugLogger.shared.debug("HISTORY_BENCH t=\(finishedAt) background=true upserts=\(upserts.count) deletes=\(deletes.count) " +"replace=\(replacing) bytes=\(records.reduce(0) { $0 + $1.payload.count }) totalMs=\((finishedAt - startedAt) * 1000)",source: "TranscriptionHistoryStore"diff --git a/Sources/Fluid/Persistence/TranscriptionHistoryStore.swift b/Sources/Fluid/Persistence/TranscriptionHistoryStore.swiftindex c5a3524d..1c30ed4d 100644--- a/Sources/Fluid/Persistence/TranscriptionHistoryStore.swift+++ b/Sources/Fluid/Persistence/TranscriptionHistoryStore.swift@@ -574,7 +574,7 @@ final class TranscriptionHistoryStore: ObservableObject {self.persistenceError = "History could not be saved. Keep FluidVoice open and retry. \(error.localizedDescription)"}}- DebugLogger.shared.info(+ DebugLogger.shared.debug("HISTORY_BENCH enqueueMs=\((ProcessInfo.processInfo.systemUptime - startedAt) * 1000) upserts=\(upserts.count) deletes=\(deletes.count)",source: "TranscriptionHistoryStore")diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex 0dd2b570..b8f55972 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -43,9 +43,9 @@ private actor TranscriptionExecutor {}private nonisolated func logTranscriptionExecutorPhase(_ phase: String, sessionID: Int?) {- guard let sessionID else { return }+ guard DebugLogger.diagnosticsEnabled, let sessionID else { return }let timestamp = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info(+ DebugLogger.shared.debug("ASR_BENCH t=\(timestamp) session=\(sessionID) final_queue_\(phase) mainThread=\(Thread.isMainThread)",source: "ASRBenchmark")@@ -56,8 +56,9 @@ private nonisolated func logStreamingProviderOperationReturn(operationID: UUID,route: String) {+ guard DebugLogger.diagnosticsEnabled else { return }let returnedAt = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info(+ DebugLogger.shared.debug("ASR_BENCH t=\(returnedAt) streaming_provider_operation_return " +"session=\(sessionID) operation=\(operationID.uuidString) route=\(route)",source: "ASRBenchmark"@@ -799,8 +800,8 @@ final class ASRService: ObservableObject {return Int(((Date().timeIntervalSince1970 - start) * 1000).rounded())}- private func benchmarkLog(_ message: String) {- DebugLogger.shared.benchmark("ASR_BENCH", message: "session=\(self.benchmarkSessionID) \(message)", source: "ASRBenchmark")+ private func benchmarkLog(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("ASR_BENCH", message: "session=\(self.benchmarkSessionID) \(message())", source: "ASRBenchmark")}/// Gets a provider for a specific model (without changing the active selection)@@ -2939,9 +2940,9 @@ final class ASRService: ObservableObject {defer { delayedFinalStatusTask.cancel() }result = try await self.transcriptionExecutor.run(benchmarkSessionID: self.benchmarkSessionID) { [provider] inlet executionStartedAt = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info("ASR_BENCH t=\(executionStartedAt) final_executor_begin mainThread=\(Thread.isMainThread)", source: "ASRBenchmark")+ DebugLogger.shared.debug("ASR_BENCH t=\(executionStartedAt) final_executor_begin mainThread=\(Thread.isMainThread)", source: "ASRBenchmark")defer {- DebugLogger.shared.info("ASR_BENCH t=\(ProcessInfo.processInfo.systemUptime) final_executor_end", source: "ASRBenchmark")+ DebugLogger.shared.debug("ASR_BENCH t=\(ProcessInfo.processInfo.systemUptime) final_executor_end", source: "ASRBenchmark")}return try await provider.transcribeFinal(pcm)}diff --git a/Sources/Fluid/Services/ClipboardService.swift b/Sources/Fluid/Services/ClipboardService.swiftindex 8dd3b992..eaabfdef 100644--- a/Sources/Fluid/Services/ClipboardService.swift+++ b/Sources/Fluid/Services/ClipboardService.swift@@ -51,6 +51,7 @@ enum ClipboardAudit {}nonisolated static func recordShortcut(type: CGEventType, event: CGEvent) {+ guard DebugLogger.diagnosticsEnabled else { return }guard let metadata = self.shortcutMetadata(type: type, event: event) else { return }DebugLogger.shared.benchmark("CLIPBOARD_INPUT", message: metadata, source: "ClipboardAudit")}@@ -70,17 +71,19 @@ enum ClipboardAudit {static func record(_ event: String,- pasteboard: NSPasteboard = .general,- detail: String = "",+ pasteboard: @autoclosure () -> NSPasteboard = .general,+ detail: @autoclosure () -> String = "",file: String = #fileID,line: Int = #line) {+ guard DebugLogger.diagnosticsEnabled else { return }+ let pasteboard = pasteboard()let startedAt = ProcessInfo.processInfo.systemUptimelet metadata = self.metadata(for: pasteboard)let auditMs = (ProcessInfo.processInfo.systemUptime - startedAt) * 1000DebugLogger.shared.benchmark("CLIPBOARD_AUDIT",- message: "schema=1 pid=\(ProcessInfo.processInfo.processIdentifier) event=\(event) caller=\(file):\(line) \(detail) \(metadata) auditMs=\(auditMs)",+ message: "schema=1 pid=\(ProcessInfo.processInfo.processIdentifier) event=\(event) caller=\(file):\(line) \(detail()) \(metadata) auditMs=\(auditMs)",source: "ClipboardAudit")}diff --git a/Sources/Fluid/Services/DebugLogger.swift b/Sources/Fluid/Services/DebugLogger.swiftindex 52e3b135..e2dee5db 100644--- a/Sources/Fluid/Services/DebugLogger.swift+++ b/Sources/Fluid/Services/DebugLogger.swift@@ -3,6 +3,16 @@ import Foundationfinal nonisolated class DebugLogger: @unchecked Sendable {static let shared = DebugLogger()+ /// Production builds exclude verbose diagnostics; local Release investigations+ /// explicitly opt in with FLUIDVOICE_DIAGNOSTICS at compile time.+ static let diagnosticsEnabled: Bool = {+ #if DEBUG || FLUIDVOICE_DIAGNOSTICS+ true+ #else+ false+ #endif+ }()+/// Request-local correlation survives actor hops without mutable global state./// Capture explicitly before handing work to a DispatchQueue or detached task.@TaskLocal static var pipelineID: String?@@ -26,7 +36,9 @@ final nonisolated class DebugLogger: @unchecked Sendable {private init() {}- func log(_ message: String, level: LogLevel = .info, source: String = "App") {+ func log(_ message: @autoclosure () -> String, level: LogLevel = .info, source: String = "App") {+ guard level != .debug || Self.diagnosticsEnabled else { return }+ let message = message()let pipelineID = Self.pipelineIDself.queue.async {self.write(message, level: level, source: source, pipelineID: pipelineID)@@ -40,6 +52,7 @@ final nonisolated class DebugLogger: @unchecked Sendable {source: String = "App",_ message: @escaping @Sendable () -> String) {+ guard level != .debug || Self.diagnosticsEnabled else { return }let pipelineID = Self.pipelineIDself.queue.async {self.write(message(), level: level, source: source, pipelineID: pipelineID)@@ -56,9 +69,11 @@ final nonisolated class DebugLogger: @unchecked Sendable {pipelineID: pipelineID)- // Always persist diagnostics so issues can be debugged even if UI debug mode is off.+ // Retain ordinary support logs in production; verbose diagnostics are gated before enqueueing.FileLogger.shared.append(line: formattedLine)+ #if DEBUG || FLUIDVOICE_DIAGNOSTICSprint(formattedLine)+ #endif}private func formatLogLine(timestamp: String, level: LogLevel, source: String, message: String, pipelineID: String?) -> String {@@ -73,9 +88,10 @@ nonisolated extension DebugLogger {self.log(message, level: .info, source: source)}- func benchmark(_ marker: String, message: String, source: String = "Benchmark") {+ func benchmark(_ marker: String, message: @autoclosure () -> String, source: String = "Benchmark") {+ guard Self.diagnosticsEnabled else { return }let now = ProcessInfo.processInfo.systemUptime- self.info("\(marker) t=\(String(format: "%.6f", now)) \(message)", source: source)+ self.info("\(marker) t=\(String(format: "%.6f", now)) \(message())", source: source)}func warning(_ message: String, source: String = "App") {@@ -86,7 +102,8 @@ nonisolated extension DebugLogger {self.log(message, level: .error, source: source)}- func debug(_ message: String, source: String = "App") {- self.log(message, level: .debug, source: source)+ func debug(_ message: @autoclosure () -> String, source: String = "App") {+ guard Self.diagnosticsEnabled else { return }+ self.log(message(), level: .debug, source: source)}}diff --git a/Sources/Fluid/Services/FluidAudioProvider.swift b/Sources/Fluid/Services/FluidAudioProvider.swiftindex 64d3d988..96634d11 100644--- a/Sources/Fluid/Services/FluidAudioProvider.swift+++ b/Sources/Fluid/Services/FluidAudioProvider.swift@@ -241,7 +241,7 @@ final class FluidAudioProvider: TranscriptionProvider {let elapsedMs = Int(((Date().timeIntervalSince1970 - startedAt) * 1000).rounded())let audioMs = Int((Double(samples.count) / 16_000.0 * 1000).rounded())let rtf = audioMs > 0 ? Double(elapsedMs) / Double(audioMs) : 0- DebugLogger.shared.info(+ DebugLogger.shared.debug("""ASR_BENCH provider_streaming_done samples=\(samples.count) audioMs=\(audioMs) \elapsedMs=\(elapsedMs) textChars=\(text.trimmingCharacters(in: .whitespacesAndNewlines).count) \@@ -354,7 +354,7 @@ final class FluidAudioProvider: TranscriptionProvider {let resetStartedAt = ProcessInfo.processInfo.systemUptimeself.resetIncrementalSession()let resetFinishedAt = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info(+ DebugLogger.shared.debug("ASR_BENCH t=\(resetFinishedAt) incremental_reset_done elapsedMs=\((resetFinishedAt - resetStartedAt) * 1000)",source: "ASRBenchmark")@@ -456,7 +456,7 @@ final class FluidAudioProvider: TranscriptionProvider {let appendFinishedAt = ProcessInfo.processInfo.systemUptimelet result = try await session.finish(finalAudioSamples: samples)let finishFinishedAt = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info(+ DebugLogger.shared.debug("ASR_BENCH incremental_final_split acceptedBefore=\(acceptedBeforeFinal) " +"appended=\(samples.count - acceptedBeforeFinal) " +"appendMs=\(Self.milliseconds(from: startedAt, to: appendFinishedAt)) " +@@ -662,10 +662,11 @@ final class FluidAudioProvider: TranscriptionProvider {usedFallback: Bool,source: String = "full") {+ guard DebugLogger.diagnosticsEnabled else { return }let elapsedMs = Int(((Date().timeIntervalSince1970 - startedAt) * 1000).rounded())let audioMs = Int((Double(samples.count) / 16_000.0 * 1000).rounded())let rtf = audioMs > 0 ? Double(elapsedMs) / Double(audioMs) : 0- DebugLogger.shared.info(+ DebugLogger.shared.debug("""ASR_BENCH provider_final_done samples=\(samples.count) audioMs=\(audioMs) \elapsedMs=\(elapsedMs) textChars=\(text.trimmingCharacters(in: .whitespacesAndNewlines).count) \@@ -681,10 +682,11 @@ final class FluidAudioProvider: TranscriptionProvider {startedAt: TimeInterval,inputSampleCount: Int) {+ guard DebugLogger.diagnosticsEnabled else { return }let elapsedMs = Int(((Date().timeIntervalSince1970 - startedAt) * 1000).rounded())let audioMs = Int((Double(sampleCount) / 16_000.0 * 1000).rounded())let rtf = audioMs > 0 ? Double(elapsedMs) / Double(audioMs) : 0- DebugLogger.shared.info(+ DebugLogger.shared.debug("""ASR_BENCH provider_streaming_delta_done samples=\(sampleCount) inputSamples=\(inputSampleCount) \audioMs=\(audioMs) elapsedMs=\(elapsedMs) textChars=\(text.count) \diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swiftindex 2da46da5..260f78e5 100644--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift@@ -2401,6 +2401,7 @@ final class GlobalHotkeyManager: NSObject {}private func logStopInput(requestedAt: TimeInterval, route: String) {+ guard DebugLogger.diagnosticsEnabled else { return }var fields = "stop_request stopRequestedAt=\(requestedAt) route=\(route)"if let input = self.currentInputTiming {fields += " inputReceivedAt=\(input.receivedAt) eventType=\(input.eventType)"diff --git a/Sources/Fluid/Services/LLMClient.swift b/Sources/Fluid/Services/LLMClient.swiftindex 31038b49..e2f9ee44 100644--- a/Sources/Fluid/Services/LLMClient.swift+++ b/Sources/Fluid/Services/LLMClient.swift@@ -1062,11 +1062,11 @@ final nonisolated class LLMClient: @unchecked Sendable {// MARK: - Logging Helpers- private func benchmark(_ config: Config, _ message: String) {- guard let id = config.benchmarkID else { return }+ private func benchmark(_ config: Config, _ message: @autoclosure () -> String) {+ guard DebugLogger.diagnosticsEnabled, let id = config.benchmarkID else { return }DebugLogger.shared.benchmark("LLM_BENCH",- message: "id=\(id) \(message)",+ message: "id=\(id) \(message())",source: "LLMBenchmark")}diff --git a/Sources/Fluid/Services/MenuBarManager.swift b/Sources/Fluid/Services/MenuBarManager.swiftindex c76c65d1..1526cf27 100644--- a/Sources/Fluid/Services/MenuBarManager.swift+++ b/Sources/Fluid/Services/MenuBarManager.swift@@ -516,8 +516,8 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {self.overlayVisible = false}- private func overlayBench(_ message: String) {- DebugLogger.shared.benchmark("OVERLAY_BENCH", message: "manager \(message)", source: "OverlayBenchmark")+ private func overlayBench(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("OVERLAY_BENCH", message: "manager \(message())", source: "OverlayBenchmark")}private func setupMenuBarSafely() {diff --git a/Sources/Fluid/Services/NotchOverlayManager.swift b/Sources/Fluid/Services/NotchOverlayManager.swiftindex c1015328..740edfee 100644--- a/Sources/Fluid/Services/NotchOverlayManager.swift+++ b/Sources/Fluid/Services/NotchOverlayManager.swift@@ -534,8 +534,8 @@ final class NotchOverlayManager {}}- private static func overlayBench(_ message: String) {- DebugLogger.shared.benchmark("OVERLAY_BENCH", message: "notch \(message)", source: "OverlayBenchmark")+ private static func overlayBench(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("OVERLAY_BENCH", message: "notch \(message())", source: "OverlayBenchmark")}private static func elapsedMs(since start: TimeInterval) -> Int {diff --git a/Sources/Fluid/Services/PasteDeliveryCoordinator.swift b/Sources/Fluid/Services/PasteDeliveryCoordinator.swiftindex f02ecc6a..d90ccb94 100644--- a/Sources/Fluid/Services/PasteDeliveryCoordinator.swift+++ b/Sources/Fluid/Services/PasteDeliveryCoordinator.swift@@ -495,8 +495,8 @@ final class SystemPasteboardManager: PasteboardManaging {)}- private func log(_ message: String) {- DebugLogger.shared.benchmark("TYPING_BENCH", message: message, source: "TypingBenchmark")+ private func log(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("TYPING_BENCH", message: message(), source: "TypingBenchmark")}private static func elapsedMs(since start: TimeInterval) -> Int {@@ -711,8 +711,8 @@ final class PasteDeliveryCoordinator {self.log("failure_restore generation=\(generation) reason=\(reason) success=\(didRestore)")}- private func log(_ message: String) {- DebugLogger.shared.benchmark("TYPING_BENCH", message: message, source: "TypingBenchmark")+ private func log(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("TYPING_BENCH", message: message(), source: "TypingBenchmark")}private static func elapsedMs(since start: TimeInterval) -> Int {diff --git a/Sources/Fluid/Services/TypingService.swift b/Sources/Fluid/Services/TypingService.swiftindex b46bf5eb..db7b1d17 100644--- a/Sources/Fluid/Services/TypingService.swift+++ b/Sources/Fluid/Services/TypingService.swift@@ -76,6 +76,7 @@ final class TypingService {/// Logging toggle (off by default). Enable by setting env FLUID_TYPING_LOGS=1/// or UserDefaults bool for key "enableTypingLogs".private nonisolated static var isLoggingEnabled: Bool {+ guard DebugLogger.diagnosticsEnabled else { return false }if let env = ProcessInfo.processInfo.environment["FLUID_TYPING_LOGS"], env == "1" { return true }return UserDefaults.standard.bool(forKey: "enableTypingLogs")}@@ -635,8 +636,8 @@ final class TypingService {}}- private func bench(_ message: String) {- DebugLogger.shared.benchmark("TYPING_BENCH", message: message, source: "TypingBenchmark")+ private func bench(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("TYPING_BENCH", message: message(), source: "TypingBenchmark")}private func recordInsertionLatency(diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swiftindex 706f8735..d96db902 100644--- a/Sources/Fluid/Views/BottomOverlayView.swift+++ b/Sources/Fluid/Views/BottomOverlayView.swift@@ -379,8 +379,8 @@ final class BottomOverlayWindowController {}}- private static func overlayBench(_ message: String) {- DebugLogger.shared.benchmark("OVERLAY_BENCH", message: message, source: "OverlayBenchmark")+ private static func overlayBench(_ message: @autoclosure () -> String) {+ DebugLogger.shared.benchmark("OVERLAY_BENCH", message: message(), source: "OverlayBenchmark")}private static func elapsedMs(since start: TimeInterval) -> Int {diff --git a/scripts/test_diagnostic_logging.py b/scripts/test_diagnostic_logging.pynew file mode 100644index 00000000..6061e5d9--- /dev/null+++ b/scripts/test_diagnostic_logging.py@@ -0,0 +1,96 @@+#!/usr/bin/env python3+"""Compile the actual logger and clipboard audit in production and diagnostic modes.++Uses a FileLogger stub and a named pasteboard; never writes the general clipboard.+Run with DEVELOPER_DIR pointing to a full Xcode installation.+"""+import os+from pathlib import Path+import subprocess+import tempfile++ROOT = Path(__file__).resolve().parents[1]+HARNESS = r'''+import AppKit+import Foundation++final class FileLogger: @unchecked Sendable {+ static let shared = FileLogger()+ let lock = NSLock()+ var lines: [String] = []+ let drained = DispatchSemaphore(value: 0)+ func append(line: String) {+ lock.lock()+ lines.append(line)+ lock.unlock()+ if line.contains("SUPPORT_END") { drained.signal() }+ }+}+final class Counter: @unchecked Sendable {+ private let lock = NSLock()+ private var value = 0+ func message() -> String { lock.lock(); defer { lock.unlock() }; value += 1; return "DIAGNOSTIC_PAYLOAD" }+ var count: Int { lock.lock(); defer { lock.unlock() }; return value }+}+@main struct Harness {+ static func main() {+ let counter = Counter()+ let boardCounter = Counter()+ func board() -> NSPasteboard {+ _ = boardCounter.message()+ return NSPasteboard(name: .init("FluidVoiceDiagnosticGateTest"))+ }+ let logger = DebugLogger.shared+ logger.debug(counter.message())+ logger.log(counter.message(), level: .debug)+ logger.benchmark("TEST_BENCH", message: counter.message())+ logger.logLazy(level: .debug) { counter.message() }+ ClipboardAudit.record("test", pasteboard: board(), detail: counter.message())+ logger.info("SUPPORT_INFO")+ logger.warning("SUPPORT_WARNING")+ logger.error("SUPPORT_ERROR")+ logger.info("SUPPORT_END")+ precondition(FileLogger.shared.drained.wait(timeout: .now() + 5) == .success)+ let enabled = DebugLogger.diagnosticsEnabled+ precondition(counter.count == (enabled ? 5 : 0), "Eager diagnostic construction")+ precondition(boardCounter.count == (enabled ? 1 : 0), "Production accessed pasteboard")+ let lines = FileLogger.shared.lines+ precondition(lines.count == (enabled ? 9 : 4), "Unexpected logging work")+ for marker in ["SUPPORT_INFO", "SUPPORT_WARNING", "SUPPORT_ERROR"] {+ precondition(lines.contains { $0.contains(marker) })+ }+ print("PASS diagnosticsEnabled=\(enabled)")+ }+}+'''+++def main():+ developer_dir = os.environ.get("DEVELOPER_DIR") or subprocess.check_output(+ ["xcode-select", "-p"], text=True+ ).strip()+ if not (Path(developer_dir) / "Platforms/MacOSX.platform").is_dir():+ raise SystemExit("Set DEVELOPER_DIR to a full Xcode installation.")+ with tempfile.TemporaryDirectory(prefix="fv-diagnostic-gate-") as folder:+ folder = Path(folder)+ harness = folder / "Harness.swift"+ harness.write_text(HARNESS)+ for name, flags in [("production", []), ("debug", ["-D", "DEBUG"]),+ ("diagnostic", ["-D", "FLUIDVOICE_DIAGNOSTICS"])]:+ binary = folder / name+ subprocess.run([+ "xcrun", "swiftc", "-parse-as-library", *flags,+ str(ROOT / "Sources/Fluid/Services/DebugLogger.swift"),+ str(ROOT / "Sources/Fluid/Services/ClipboardService.swift"),+ str(harness), "-o", str(binary),+ ], check=True)+ output = subprocess.check_output([str(binary)], text=True)+ if name == "production":+ assert output == "PASS diagnosticsEnabled=false\n", output+ else:+ assert "PASS diagnosticsEnabled=true" in output, output+ print(f"PASS {name}: logging and message evaluation gates")+++if __name__ == "__main__":+ main()