mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-04-27 15:07:41 +00:00
- Update to swift-tools-version 6.0 and enable StrictConcurrency - Make all data models and types Sendable for concurrency safety - Migrate commands from ParsableCommand to AsyncParsableCommand - Remove AsyncUtils.swift and synchronous bridging patterns - Update WindowBounds property names to snake_case for consistency - Ensure all error types conform to Sendable protocol - Add comprehensive Swift 6 migration documentation This migration enables full Swift 6 concurrency checking and data race safety while maintaining backward compatibility with the existing API. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
1.8 KiB
Swift
69 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
final class Logger: @unchecked Sendable {
|
|
static let shared = Logger()
|
|
private var debugLogs: [String] = []
|
|
private var isJsonOutputMode = false
|
|
private let queue = DispatchQueue(label: "logger.queue", attributes: .concurrent)
|
|
|
|
private init() {}
|
|
|
|
func setJsonOutputMode(_ enabled: Bool) {
|
|
queue.async(flags: .barrier) {
|
|
self.isJsonOutputMode = enabled
|
|
// Don't clear logs automatically - let tests manage this explicitly
|
|
}
|
|
}
|
|
|
|
func debug(_ message: String) {
|
|
queue.async(flags: .barrier) {
|
|
if self.isJsonOutputMode {
|
|
self.debugLogs.append(message)
|
|
} else {
|
|
fputs("DEBUG: \(message)\n", stderr)
|
|
}
|
|
}
|
|
}
|
|
|
|
func info(_ message: String) {
|
|
queue.async(flags: .barrier) {
|
|
if self.isJsonOutputMode {
|
|
self.debugLogs.append("INFO: \(message)")
|
|
} else {
|
|
fputs("INFO: \(message)\n", stderr)
|
|
}
|
|
}
|
|
}
|
|
|
|
func warn(_ message: String) {
|
|
queue.async(flags: .barrier) {
|
|
if self.isJsonOutputMode {
|
|
self.debugLogs.append("WARN: \(message)")
|
|
} else {
|
|
fputs("WARN: \(message)\n", stderr)
|
|
}
|
|
}
|
|
}
|
|
|
|
func error(_ message: String) {
|
|
queue.async(flags: .barrier) {
|
|
if self.isJsonOutputMode {
|
|
self.debugLogs.append("ERROR: \(message)")
|
|
} else {
|
|
fputs("ERROR: \(message)\n", stderr)
|
|
}
|
|
}
|
|
}
|
|
|
|
func getDebugLogs() -> [String] {
|
|
queue.sync {
|
|
self.debugLogs
|
|
}
|
|
}
|
|
|
|
func clearDebugLogs() {
|
|
queue.async(flags: .barrier) {
|
|
self.debugLogs.removeAll()
|
|
}
|
|
}
|
|
}
|