diff --git a/Sources/ElixxirDAppsSDK/Legacy/LogLevelConfigurator.swift b/Sources/ElixxirDAppsSDK/Legacy/LogLevelConfigurator.swift deleted file mode 100644 index 6137fc838a143b09ece6ca96a07a1334108cf44f..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/Legacy/LogLevelConfigurator.swift +++ /dev/null @@ -1,31 +0,0 @@ -import Bindings - -public struct LogLevelConfigurator { - public var set: (LogLevel) throws -> Void - - public func callAsFunction(logLevel: LogLevel) throws { - try set(logLevel) - } -} - -extension LogLevelConfigurator { - public static let live = LogLevelConfigurator { logLevel in - var error: NSError? - let result = BindingsLogLevel(logLevel.rawValue, &error) - if let error = error { - throw error - } - if !result { - fatalError("BindingsLogLevel returned `false` without providing error") - } - } -} - -#if DEBUG -extension LogLevelConfigurator { - public static let failing = LogLevelConfigurator { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif diff --git a/Sources/ElixxirDAppsSDK/Legacy/LogLevel.swift b/Sources/ElixxirDAppsSDK/LogLevel.swift similarity index 100% rename from Sources/ElixxirDAppsSDK/Legacy/LogLevel.swift rename to Sources/ElixxirDAppsSDK/LogLevel.swift diff --git a/Sources/ElixxirDAppsSDK/SetLogLevel.swift b/Sources/ElixxirDAppsSDK/SetLogLevel.swift new file mode 100644 index 0000000000000000000000000000000000000000..487bfd8e23c402c17b2f712ebf92bec520bbcc97 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/SetLogLevel.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct SetLogLevel { + public var run: (LogLevel) throws -> Bool + + public func callAsFunction(_ logLevel: LogLevel) throws -> Bool { + try run(logLevel) + } +} + +extension SetLogLevel { + public static let live = SetLogLevel { logLevel in + var error: NSError? + let result = BindingsLogLevel(logLevel.rawValue, &error) + if let error = error { + throw error + } + return result + } +} + +extension SetLogLevel { + public static let unimplemented = SetLogLevel( + run: XCTUnimplemented("\(Self.self)") + ) +}