chore: vendor swabble and add speech usage strings

This commit is contained in:
Peter Steinberger
2025-12-06 02:10:20 +01:00
parent 4e7d905783
commit e1c9885566
34 changed files with 1577 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
import Foundation
public enum LogLevel: String, Comparable, CaseIterable, Sendable {
case trace, debug, info, warn, error
var rank: Int {
switch self {
case .trace: 0
case .debug: 1
case .info: 2
case .warn: 3
case .error: 4
}
}
public static func < (lhs: LogLevel, rhs: LogLevel) -> Bool { lhs.rank < rhs.rank }
}
public struct Logger: Sendable {
public let level: LogLevel
public init(level: LogLevel) { self.level = level }
public func log(_ level: LogLevel, _ message: String) {
guard level >= self.level else { return }
let ts = ISO8601DateFormatter().string(from: Date())
print("[\(level.rawValue.uppercased())] \(ts) | \(message)")
}
public func trace(_ msg: String) { self.log(.trace, msg) }
public func debug(_ msg: String) { self.log(.debug, msg) }
public func info(_ msg: String) { self.log(.info, msg) }
public func warn(_ msg: String) { self.log(.warn, msg) }
public func error(_ msg: String) { self.log(.error, msg) }
}
extension LogLevel {
public init?(configValue: String) {
self.init(rawValue: configValue.lowercased())
}
}