diff --git a/Source/LDSwiftEventSource.swift b/Source/LDSwiftEventSource.swift index 1225e5b..cd10eb7 100644 --- a/Source/LDSwiftEventSource.swift +++ b/Source/LDSwiftEventSource.swift @@ -298,7 +298,8 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate { readyState = .closed let sleep = reconnectionTimer.reconnectDelay(baseDelay: currentRetry) - logger.log(.info, "Waiting %.3f seconds before reconnecting...", sleep) + // this formatting shenanigans is to workaround String not implementing CVarArg on Swift<5.4 on Linux + logger.log(.info, "Waiting %@ seconds before reconnecting...", String(format: "%.3f", sleep)) delegateQueue.asyncAfter(deadline: .now() + sleep) { [weak self] in self?.connect() } @@ -326,7 +327,8 @@ class EventSourceDelegate: NSObject, URLSessionDataDelegate { config.handler.onOpened() completionHandler(.allow) } else { - logger.log(.info, "Unsuccessful response: %d", statusCode) + // this formatting shenanigans is to workaround String not implementing CVarArg on Swift<5.4 on Linux + logger.log(.info, "Unsuccessful response: %@", String(format: "%d", statusCode)) if dispatchError(error: UnsuccessfulResponseError(responseCode: statusCode)) == .shutdown { logger.log(.info, "Connection has been explicitly shut down by error handler") readyState = .shutdown diff --git a/Source/Logs.swift b/Source/Logs.swift index 46d62bd..9a384f0 100644 --- a/Source/Logs.swift +++ b/Source/Logs.swift @@ -6,8 +6,8 @@ import os.log protocol InternalLogging { func log(_ level: Level, _ staticMsg: StaticString) - func log(_ level: Level, _ staticMsg: StaticString, _ arg: CVarArg) - func log(_ level: Level, _ staticMsg: StaticString, _ arg1: CVarArg, _ arg2: CVarArg) + func log(_ level: Level, _ staticMsg: StaticString, _ arg: String) + func log(_ level: Level, _ staticMsg: StaticString, _ arg1: String, _ arg2: String) } enum Level { @@ -35,11 +35,11 @@ class OSLogAdapter: InternalLogging { os_log(staticMsg, log: self.osLog, type: level.osLogType) } - func log(_ level: Level, _ staticMsg: StaticString, _ arg: CVarArg) { + func log(_ level: Level, _ staticMsg: StaticString, _ arg: String) { os_log(staticMsg, log: self.osLog, type: level.osLogType, arg) } - func log(_ level: Level, _ staticMsg: StaticString, _ arg1: CVarArg, _ arg2: CVarArg) { + func log(_ level: Level, _ staticMsg: StaticString, _ arg1: String, _ arg2: String) { os_log(staticMsg, log: self.osLog, type: level.osLogType, arg1, arg2) } } @@ -47,6 +47,6 @@ class OSLogAdapter: InternalLogging { class NoOpLogging: InternalLogging { func log(_ level: Level, _ staticMsg: StaticString) {} - func log(_ level: Level, _ staticMsg: StaticString, _ arg: CVarArg) {} - func log(_ level: Level, _ staticMsg: StaticString, _ arg1: CVarArg, _ arg2: CVarArg) {} + func log(_ level: Level, _ staticMsg: StaticString, _ arg: String) {} + func log(_ level: Level, _ staticMsg: StaticString, _ arg1: String, _ arg2: String) {} }