mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-06-29 05:39:33 +00:00
- Configure CI to run on macOS-latest - Test with Node.js 20.x and 22.x - Run npm build and tests on push/PR 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
54 lines
No EOL
1.2 KiB
Swift
54 lines
No EOL
1.2 KiB
Swift
import Foundation
|
|
|
|
class Logger {
|
|
static let shared = Logger()
|
|
private var debugLogs: [String] = []
|
|
private var isJsonOutputMode = false
|
|
|
|
private init() {}
|
|
|
|
func setJsonOutputMode(_ enabled: Bool) {
|
|
isJsonOutputMode = enabled
|
|
debugLogs.removeAll()
|
|
}
|
|
|
|
func debug(_ message: String) {
|
|
if isJsonOutputMode {
|
|
debugLogs.append(message)
|
|
} else {
|
|
fputs("DEBUG: \(message)\n", stderr)
|
|
}
|
|
}
|
|
|
|
func info(_ message: String) {
|
|
if isJsonOutputMode {
|
|
debugLogs.append("INFO: \(message)")
|
|
} else {
|
|
fputs("INFO: \(message)\n", stderr)
|
|
}
|
|
}
|
|
|
|
func warn(_ message: String) {
|
|
if isJsonOutputMode {
|
|
debugLogs.append("WARN: \(message)")
|
|
} else {
|
|
fputs("WARN: \(message)\n", stderr)
|
|
}
|
|
}
|
|
|
|
func error(_ message: String) {
|
|
if isJsonOutputMode {
|
|
debugLogs.append("ERROR: \(message)")
|
|
} else {
|
|
fputs("ERROR: \(message)\n", stderr)
|
|
}
|
|
}
|
|
|
|
func getDebugLogs() -> [String] {
|
|
return debugLogs
|
|
}
|
|
|
|
func clearDebugLogs() {
|
|
debugLogs.removeAll()
|
|
}
|
|
} |