Skip to content

Commit 69e545d

Browse files
author
Ivo Bellin Salarin
committed
chore: avoid print
1 parent f906e63 commit 69e545d

File tree

11 files changed

+63
-38
lines changed

11 files changed

+63
-38
lines changed

Recap/Audio/Processing/FileManagement/RecordingFileManagerHelper.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import OSLog
23

34
protocol RecordingFileManagerHelperType {
45
func getBaseDirectory() -> URL
@@ -8,6 +9,7 @@ protocol RecordingFileManagerHelperType {
89

910
final class RecordingFileManagerHelper: RecordingFileManagerHelperType {
1011
private let userPreferencesRepository: UserPreferencesRepositoryType
12+
private let logger = Logger(subsystem: AppConstants.Logging.subsystem, category: String(describing: RecordingFileManagerHelper.self))
1113

1214
init(userPreferencesRepository: UserPreferencesRepositoryType) {
1315
self.userPreferencesRepository = userPreferencesRepository
@@ -28,33 +30,33 @@ final class RecordingFileManagerHelper: RecordingFileManagerHelperType {
2830
bookmarkDataIsStale: &isStale
2931
)
3032

31-
print("📂 Resolved bookmark to: \(url.path), isStale: \(isStale)")
33+
logger.info("📂 Resolved bookmark to: \(url.path, privacy: .public), isStale: \(isStale, privacy: .public)")
3234

3335
// Start accessing the security-scoped resource
3436
guard url.startAccessingSecurityScopedResource() else {
35-
print("❌ Failed to start accessing security-scoped resource")
37+
logger.error("❌ Failed to start accessing security-scoped resource")
3638
// Fall through to default if we can't access
3739
return defaultDirectory()
3840
}
3941

40-
print("✅ Successfully started accessing security-scoped resource")
42+
logger.info("✅ Successfully started accessing security-scoped resource")
4143
return url
4244
} catch {
43-
print("❌ Bookmark resolution failed: \(error)")
45+
logger.error("❌ Bookmark resolution failed: \(error.localizedDescription, privacy: .public)")
4446
// Fall through to default if bookmark resolution fails
4547
}
4648
}
4749

4850
// Fallback: try the path string (won't work for sandboxed access but kept for backwards compatibility)
4951
if let customPath = defaults.string(forKey: "customTmpDirectoryPath") {
50-
print("📂 Trying fallback path: \(customPath)")
52+
logger.info("📂 Trying fallback path: \(customPath, privacy: .public)")
5153
let url = URL(fileURLWithPath: customPath)
5254
if FileManager.default.fileExists(atPath: url.path) {
5355
return url
5456
}
5557
}
5658

57-
print("📂 Using default directory")
59+
logger.info("📂 Using default directory")
5860
return defaultDirectory()
5961
}
6062

Recap/Helpers/GlobalShortcut/GlobalShortcutManager.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Cocoa
22
import Carbon
3+
import OSLog
34

45
@MainActor
56
protocol GlobalShortcutDelegate: AnyObject {
@@ -14,6 +15,7 @@ final class GlobalShortcutManager {
1415

1516
// Default shortcut: Cmd+R
1617
private var currentShortcut: (keyCode: UInt32, modifiers: UInt32) = (keyCode: 15, modifiers: UInt32(cmdKey)) // 'R' key with Cmd
18+
private let logger = Logger(subsystem: AppConstants.Logging.subsystem, category: String(describing: GlobalShortcutManager.self))
1719

1820
init() {
1921
setupEventHandling()
@@ -55,7 +57,7 @@ final class GlobalShortcutManager {
5557
)
5658

5759
guard status == noErr else {
58-
print("Failed to install event handler: \(status)")
60+
logger.error("Failed to install event handler: \(status, privacy: .public)")
5961
return
6062
}
6163

@@ -70,11 +72,11 @@ final class GlobalShortcutManager {
7072
)
7173

7274
guard status2 == noErr else {
73-
print("Failed to register hot key: \(status2)")
75+
logger.error("Failed to register hot key: \(status2, privacy: .public)")
7476
return
7577
}
76-
77-
print("Global shortcut registered: Cmd+R")
78+
79+
logger.info("Global shortcut registered: Cmd+R")
7880
}
7981

8082
private func unregisterShortcut() {

Recap/MenuBar/Manager/MenuBarPanelManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22
import AppKit
33
import Combine
4+
import OSLog
45

56
@MainActor
67
final class MenuBarPanelManager: MenuBarPanelManagerType, ObservableObject {
@@ -35,6 +36,7 @@ final class MenuBarPanelManager: MenuBarPanelManagerType, ObservableObject {
3536
let generalSettingsViewModel: GeneralSettingsViewModel
3637
let userPreferencesRepository: UserPreferencesRepositoryType
3738
let meetingDetectionService: any MeetingDetectionServiceType
39+
private let logger = Logger(subsystem: AppConstants.Logging.subsystem, category: String(describing: MenuBarPanelManager.self))
3840

3941
init(
4042
statusBarManager: StatusBarManagerType,
@@ -71,7 +73,7 @@ final class MenuBarPanelManager: MenuBarPanelManagerType, ObservableObject {
7173
recapViewModel.$isRecording
7274
.receive(on: DispatchQueue.main)
7375
.sink { [weak self] isRecording in
74-
print("🔴 Recording state changed to: \(isRecording)")
76+
self?.logger.info("🔴 Recording state changed to: \(isRecording, privacy: .public)")
7577
self?.statusBarManager.setRecordingState(isRecording)
7678
}
7779
.store(in: &cancellables)

Recap/MenuBar/Manager/StatusBar/StatusBarManager.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import AppKit
2+
import OSLog
23

34
@MainActor
45
protocol StatusBarDelegate: AnyObject {
@@ -15,6 +16,7 @@ final class StatusBarManager: StatusBarManagerType {
1516
weak var delegate: StatusBarDelegate?
1617
private var themeObserver: NSObjectProtocol?
1718
private var isRecording = false
19+
private let logger = Logger(subsystem: AppConstants.Logging.subsystem, category: String(describing: StatusBarManager.self))
1820

1921
init() {
2022
setupStatusItem()
@@ -43,7 +45,7 @@ final class StatusBarManager: StatusBarManagerType {
4345
private func updateIconForCurrentTheme() {
4446
guard let button = statusItem?.button else { return }
4547

46-
print("🎨 updateIconForCurrentTheme called, isRecording: \(isRecording)")
48+
logger.debug("🎨 updateIconForCurrentTheme called, isRecording: \(self.isRecording, privacy: .public)")
4749

4850
// Always use the black icon, regardless of theme
4951
if let image = NSImage(named: "barIcon-dark") {
@@ -53,29 +55,29 @@ final class StatusBarManager: StatusBarManagerType {
5355
tintedImage.isTemplate = false
5456
button.image = tintedImage
5557
button.contentTintColor = nil
56-
print("🎨 Applied red tinted image")
58+
logger.debug("🎨 Applied red tinted image")
5759
} else {
5860
// Use original image
5961
let workingImage = image.copy() as! NSImage
6062
workingImage.isTemplate = true
6163
button.image = workingImage
6264
button.contentTintColor = nil
63-
print("🎨 Applied normal image")
65+
logger.debug("🎨 Applied normal image")
6466
}
6567
} else if let fallback = NSImage(named: "barIcon") {
6668
if isRecording {
6769
// Create red-tinted version
6870
let tintedImage = createTintedImage(from: fallback, tint: .systemRed)
6971
button.image = tintedImage
7072
button.contentTintColor = nil
71-
print("🎨 Applied red tinted fallback image")
73+
logger.debug("🎨 Applied red tinted fallback image")
7274
} else {
7375
// Use original image
7476
let workingImage = fallback.copy() as! NSImage
7577
workingImage.isTemplate = true
7678
button.image = workingImage
7779
button.contentTintColor = nil
78-
print("🎨 Applied normal fallback image")
80+
logger.debug("🎨 Applied normal fallback image")
7981
}
8082
}
8183
}
@@ -99,10 +101,10 @@ final class StatusBarManager: StatusBarManagerType {
99101
}
100102

101103
func setRecordingState(_ recording: Bool) {
102-
print("🎯 StatusBarManager.setRecordingState called with: \(recording)")
104+
logger.info("🎯 StatusBarManager.setRecordingState called with: \(recording, privacy: .public)")
103105
isRecording = recording
104106
updateIconForCurrentTheme()
105-
print("🎯 Icon updated, isRecording = \(isRecording)")
107+
logger.info("🎯 Icon updated, isRecording = \(self.isRecording, privacy: .public)")
106108
}
107109

108110
@objc private func handleButtonClick(_ sender: NSStatusBarButton) {

Recap/Services/Processing/ProcessingCoordinator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ final class ProcessingCoordinator: ProcessingCoordinatorType {
278278
)
279279
delegate?.processingStateDidChange(recordingID: recording.id, newState: failureState)
280280
} catch {
281-
print("Failed to update recording state after error: \(error)")
281+
logger.error("Failed to update recording state after error: \(error.localizedDescription, privacy: .public)")
282282
}
283283

284284
delegate?.processingDidFail(recordingID: recording.id, error: error)

Recap/Services/Transcription/TranscriptionService.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import Foundation
2+
import OSLog
23
import WhisperKit
34

45
@MainActor
56
final class TranscriptionService: TranscriptionServiceType {
67
private let whisperModelRepository: WhisperModelRepositoryType
78
private var whisperKit: WhisperKit?
89
private var loadedModelName: String?
10+
private let logger = Logger(subsystem: AppConstants.Logging.subsystem, category: String(describing: TranscriptionService.self))
911

1012
init(whisperModelRepository: WhisperModelRepositoryType) {
1113
self.whisperModelRepository = whisperModelRepository
@@ -77,7 +79,7 @@ final class TranscriptionService: TranscriptionServiceType {
7779

7880
private func loadModel(_ modelName: String, isDownloaded: Bool) async throws {
7981
do {
80-
print("Loading WhisperKit model: \(modelName), isDownloaded: \(isDownloaded)")
82+
logger.info("Loading WhisperKit model: \(modelName, privacy: .public), isDownloaded: \(isDownloaded, privacy: .public)")
8183

8284
// Always try to download/load the model, as WhisperKit will handle caching
8385
// The isDownloaded flag is just for UI purposes, but WhisperKit manages its own cache
@@ -86,24 +88,24 @@ final class TranscriptionService: TranscriptionServiceType {
8688
modelRepo: "argmaxinc/whisperkit-coreml",
8789
modelFolder: nil,
8890
download: true, // Always allow download, WhisperKit will use cache if available
89-
progressCallback: { progress in
90-
print("WhisperKit download progress: \(progress.fractionCompleted)")
91+
progressCallback: { [weak self] progress in
92+
self?.logger.info("WhisperKit download progress: \(progress.fractionCompleted, privacy: .public)")
9193
}
9294
)
9395

94-
print("WhisperKit model loaded successfully: \(modelName)")
96+
logger.info("WhisperKit model loaded successfully: \(modelName, privacy: .public)")
9597
self.whisperKit = newWhisperKit
9698
self.loadedModelName = modelName
9799

98100
// Mark as downloaded in our repository if not already marked
99101
if !isDownloaded {
100102
let modelInfo = await WhisperKit.getModelSizeInfo(for: modelName)
101103
try await whisperModelRepository.markAsDownloaded(name: modelName, sizeInMB: Int64(modelInfo.totalSizeMB))
102-
print("Model marked as downloaded: \(modelName), size: \(modelInfo.totalSizeMB) MB")
104+
logger.info("Model marked as downloaded: \(modelName, privacy: .public), size: \(modelInfo.totalSizeMB, privacy: .public) MB")
103105
}
104106

105107
} catch {
106-
print("Failed to load WhisperKit model \(modelName): \(error)")
108+
logger.error("Failed to load WhisperKit model \(modelName, privacy: .public): \(error.localizedDescription, privacy: .public)")
107109
throw TranscriptionError.modelLoadingFailed("Failed to load model \(modelName): \(error.localizedDescription)")
108110
}
109111
}

Recap/UIComponents/Buttons/DownloadPillButton.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import SwiftUI
2+
import OSLog
3+
4+
private let downloadPillButtonPreviewLogger = Logger(subsystem: AppConstants.Logging.subsystem, category: "DownloadPillButtonPreview")
25

36
struct DownloadPillButton: View {
47
let text: String
@@ -78,31 +81,31 @@ struct DownloadPillButton: View {
7881
isDownloading: false,
7982
downloadProgress: 0.0
8083
) {
81-
print("Download started")
84+
downloadPillButtonPreviewLogger.info("Download started")
8285
}
8386

8487
DownloadPillButton(
8588
text: "Downloading",
8689
isDownloading: true,
8790
downloadProgress: 0.3
8891
) {
89-
print("Download in progress")
92+
downloadPillButtonPreviewLogger.info("Download in progress (0.3)")
9093
}
9194

9295
DownloadPillButton(
9396
text: "Downloading",
9497
isDownloading: true,
9598
downloadProgress: 0.7
9699
) {
97-
print("Download in progress")
100+
downloadPillButtonPreviewLogger.info("Download in progress (0.7)")
98101
}
99102

100103
DownloadPillButton(
101104
text: "Downloaded",
102105
isDownloading: false,
103106
downloadProgress: 1.0
104107
) {
105-
print("Download complete")
108+
downloadPillButtonPreviewLogger.info("Download complete")
106109
}
107110
}
108111
.padding()

Recap/UIComponents/Buttons/PillButton.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import SwiftUI
2+
import OSLog
3+
4+
private let pillButtonPreviewLogger = Logger(subsystem: AppConstants.Logging.subsystem, category: "PillButtonPreview")
25

36
struct PillButton: View {
47
let text: String
@@ -54,11 +57,11 @@ struct PillButton: View {
5457
#Preview {
5558
VStack(spacing: 20) {
5659
PillButton(text: "Start Recording", icon: "mic.fill") {
57-
print("Recording started")
60+
pillButtonPreviewLogger.info("Recording started")
5861
}
5962

6063
PillButton(text: "Button", icon: nil) {
61-
print("Button tapped")
64+
pillButtonPreviewLogger.info("Button tapped")
6265
}
6366
}
6467
.padding()

Recap/UIComponents/Buttons/SummaryActionButton.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import SwiftUI
2+
import OSLog
3+
4+
private let summaryActionButtonPreviewLogger = Logger(subsystem: AppConstants.Logging.subsystem, category: "SummaryActionButtonPreview")
25

36
struct SummaryActionButton: View {
47
let text: String
@@ -95,15 +98,15 @@ struct SummaryActionButton: View {
9598
text: "Copy",
9699
icon: "doc.on.doc"
97100
) {
98-
print("Copy tapped")
101+
summaryActionButtonPreviewLogger.info("Copy tapped")
99102
}
100103

101104
SummaryActionButton(
102105
text: "Retry",
103106
icon: "arrow.clockwise",
104107
isSecondary: true
105108
) {
106-
print("Retry tapped")
109+
summaryActionButtonPreviewLogger.info("Retry tapped")
107110
}
108111
}
109112

@@ -113,4 +116,4 @@ struct SummaryActionButton: View {
113116
}
114117
.padding(40)
115118
.background(Color.black)
116-
}
119+
}

Recap/UIComponents/Buttons/TabButton.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import SwiftUI
2+
import OSLog
3+
4+
private let tabButtonPreviewLogger = Logger(subsystem: AppConstants.Logging.subsystem, category: "TabButtonPreview")
25

36
struct TabButton: View {
47
let text: String
@@ -41,13 +44,13 @@ struct TabButton: View {
4144
#Preview {
4245
HStack(spacing: 8) {
4346
TabButton(text: "General", isSelected: true) {
44-
print("General selected")
47+
tabButtonPreviewLogger.info("General selected")
4548
}
4649

4750
TabButton(text: "Whisper Models", isSelected: false) {
48-
print("Whisper Models selected")
51+
tabButtonPreviewLogger.info("Whisper Models selected")
4952
}
5053
}
5154
.padding()
5255
.background(Color.black)
53-
}
56+
}

0 commit comments

Comments
 (0)