diff --git a/PapyrusCore/Sources/Interceptors/CurlInterceptor.swift b/PapyrusCore/Sources/Interceptors/CurlInterceptor.swift index d7f896e..a29b374 100644 --- a/PapyrusCore/Sources/Interceptors/CurlInterceptor.swift +++ b/PapyrusCore/Sources/Interceptors/CurlInterceptor.swift @@ -9,23 +9,23 @@ public struct CurlLogger { case onError } - let loggingFn: (String) -> Void + let logHandler: (String) -> Void let condition: Condition - /// An `Interceptor` that calls a loggingFn with a request based on a condition + /// An `Interceptor` that calls a logHandler with a request based on a condition /// - Parameters: /// - condition: must be met for the logging function to be called - /// - loggingFn: a function that implements logging. defaults to `print()` - public init(when condition: Condition, using loggingFn: @escaping (String) -> Void = { print($0) }) { + /// - logHandler: a function that implements logging. defaults to `print()` + public init(when condition: Condition, using logHandler: @escaping (String) -> Void = { print($0) }) { self.condition = condition - self.loggingFn = loggingFn + self.logHandler = logHandler } } extension CurlLogger: Interceptor { public func intercept(req: any Request, next: (any Request) async throws -> any Response) async throws -> any Response { if condition == .always { - loggingFn(req.curl(sortedHeaders: true)) + logHandler(req.curl(sortedHeaders: true)) } do { @@ -33,7 +33,7 @@ extension CurlLogger: Interceptor { return res } catch { if condition == .onError { - loggingFn(req.curl(sortedHeaders: true)) + logHandler(req.curl(sortedHeaders: true)) } throw error }