Skip to content

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

Added file logging locally - to help debug issues from users

altic-dev1cee97d327ed
diff --git a/Info.plist b/Info.plist
index 28d73a92..f20b83c8 100644
--- a/Info.plist
+++ b/Info.plist
@@ -11,7 +11,7 @@
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleShortVersionString</key>
- <string>1.2</string>
+ <string>1.3</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSApplicationCategoryType</key>
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 9f10f9a0..f7b7d4d9 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -1753,6 +1753,20 @@ struct ContentView: View {
.foregroundStyle(.orange)
}
+ Button {
+ let url = FileLogger.shared.currentLogFileURL()
+ if FileManager.default.fileExists(atPath: url.path) {
+ NSWorkspace.shared.activateFileViewerSelecting([url])
+ } else {
+ DebugLogger.shared.info("Log file not found at \(url.path)", source: "ContentView")
+ }
+ } label: {
+ Label("Reveal Log File", systemImage: "doc.richtext")
+ .labelStyle(.titleAndIcon)
+ }
+ .buttonStyle(GlassButtonStyle())
+ .buttonHoverEffect()
+
Text("Enable debug logging to see detailed information about app operations. This can help with troubleshooting but may impact performance. Error and warning messages are always shown regardless of this setting.")
.font(.caption)
.foregroundStyle(.secondary)
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swift
index 1f68e4f9..e02fa3e0 100644
--- a/Sources/Fluid/Services/ASRService.swift
+++ b/Sources/Fluid/Services/ASRService.swift
@@ -497,11 +497,15 @@ final class ASRService: ObservableObject
DispatchQueue.main.async {
self.isDownloadingModel = true
self.modelDownloadProgress = 0.0
+ DebugLogger.shared.info("Model download flagged as in-progress (progress=0)", source: "ASRService")
}
+ DebugLogger.shared.debug("Invoking AsrModels.downloadAndLoad()", source: "ASRService")
let models = try await AsrModels.downloadAndLoad()
+ DebugLogger.shared.info("AsrModels.downloadAndLoad() returned successfully", source: "ASRService")
DispatchQueue.main.async {
self.isDownloadingModel = false
self.modelDownloadProgress = 1.0
+ DebugLogger.shared.info("Model download marked complete (progress=1)", source: "ASRService")
}
DebugLogger.shared.debug("FluidAudio models loaded successfully (v3)", source: "ASRService")
@@ -526,6 +530,13 @@ final class ASRService: ObservableObject
{
DebugLogger.shared.error("ASR initialization failed with error: \(error)", source: "ASRService")
DebugLogger.shared.error("Error details: \(error.localizedDescription)", source: "ASRService")
+ DispatchQueue.main.async {
+ if self.isDownloadingModel {
+ DebugLogger.shared.warning("Model download aborted due to error; resetting progress state", source: "ASRService")
+ }
+ self.isDownloadingModel = false
+ self.modelDownloadProgress = 0.0
+ }
throw error
}
isAsrReady = true
diff --git a/Sources/Fluid/Services/DebugLogger.swift b/Sources/Fluid/Services/DebugLogger.swift
index e63f4c37..19f16940 100644
--- a/Sources/Fluid/Services/DebugLogger.swift
+++ b/Sources/Fluid/Services/DebugLogger.swift
@@ -48,9 +48,12 @@ class DebugLogger: ObservableObject {
// Check if debug logging is enabled for debug level, but always show errors and warnings
let shouldLogToConsole = level == .error || level == .warning || SettingsStore.shared.enableDebugLogs
+ let formattedLine = "[\(entry.formattedTimestamp)] [\(level.rawValue)] [\(source)] \(message)"
+ FileLogger.shared.append(line: formattedLine)
+
if shouldLogToConsole {
// Also print to console for Xcode debugging
- print("[\(entry.formattedTimestamp)] [\(level.rawValue)] [\(source)] \(message)")
+ print(formattedLine)
}
DispatchQueue.main.async {
diff --git a/Sources/Fluid/Services/FileLogger.swift b/Sources/Fluid/Services/FileLogger.swift
new file mode 100644
index 00000000..8a63177d
--- /dev/null
+++ b/Sources/Fluid/Services/FileLogger.swift
@@ -0,0 +1,102 @@
+import Foundation
+
+/// A lightweight file-backed logger that mirrors in-app debug logs to disk for diagnostics.
+final class FileLogger
+{
+ static let shared = FileLogger()
+
+ private let queue = DispatchQueue(label: "file.logger.queue", qos: .utility)
+ private let fileManager = FileManager.default
+ private let logDirectory: URL
+ private let logFileURL: URL
+ private let backupLogURL: URL
+ private let maxLogFileSize: UInt64 = 1 * 1024 * 1024 // 1 MB limit per log file
+
+ private init()
+ {
+ let baseDirectory = fileManager.urls(for: .libraryDirectory, in: .userDomainMask).first ?? URL(fileURLWithPath: NSTemporaryDirectory())
+ logDirectory = baseDirectory.appendingPathComponent("Logs/Fluid", isDirectory: true)
+ logFileURL = logDirectory.appendingPathComponent("fluid.log", isDirectory: false)
+ backupLogURL = logDirectory.appendingPathComponent("fluid.log.1", isDirectory: false)
+
+ queue.sync {
+ createLogDirectoryIfNeeded()
+ rotateIfNeeded(force: false)
+ }
+ }
+
+ func append(line: String)
+ {
+ queue.async { [weak self] in
+ guard let self = self else { return }
+ self.createLogDirectoryIfNeeded()
+ self.rotateIfNeeded(force: false)
+ let data = (line + "\n").data(using: .utf8) ?? Data()
+ if !self.fileManager.fileExists(atPath: self.logFileURL.path)
+ {
+ self.fileManager.createFile(atPath: self.logFileURL.path, contents: data)
+ }
+ else if let handle = try? FileHandle(forWritingTo: self.logFileURL)
+ {
+ do {
+ try handle.seekToEnd()
+ try handle.write(contentsOf: data)
+ try handle.close()
+ }
+ catch
+ {
+ try? handle.close()
+ }
+ }
+ }
+ }
+
+ func currentLogFileURL() -> URL
+ {
+ return logFileURL
+ }
+
+ // MARK: - Private helpers
+
+ private func createLogDirectoryIfNeeded()
+ {
+ guard !fileManager.fileExists(atPath: logDirectory.path) else { return }
+ do
+ {
+ try fileManager.createDirectory(at: logDirectory, withIntermediateDirectories: true)
+ }
+ catch
+ {
+ // If the directory cannot be created, fall back to /tmp
+ }
+ }
+
+ private func rotateIfNeeded(force: Bool)
+ {
+ guard fileManager.fileExists(atPath: logFileURL.path) else { return }
+
+ let shouldRotate: Bool
+ if force
+ {
+ shouldRotate = true
+ }
+ else
+ {
+ let attributes = try? fileManager.attributesOfItem(atPath: logFileURL.path)
+ let size = attributes?[.size] as? UInt64 ?? 0
+ shouldRotate = size >= maxLogFileSize
+ }
+
+ guard shouldRotate else { return }
+
+ // Remove existing backup if present
+ if fileManager.fileExists(atPath: backupLogURL.path)
+ {
+ try? fileManager.removeItem(at: backupLogURL)
+ }
+
+ // Move current log to backup and create a fresh file
+ try? fileManager.moveItem(at: logFileURL, to: backupLogURL)
+ fileManager.createFile(atPath: logFileURL.path, contents: nil)
+ }
+}