NetworkLoggerPlugin

open class NetworkLoggerPlugin : Plugin

Plugin, that can be used to log network success and failure responses.

  • Log successful requests

    Declaration

    Swift

    open var logSuccess: Bool
  • Log unsuccessful requests

    Declaration

    Swift

    open var logFailures: Bool
  • Log failures produced when request is cancelled. This property only works, if logFailures property is set to true.

    Declaration

    Swift

    open var logCancelledRequests: Bool
  • Creates ‘NetworkLoggerPlugin’

    Declaration

    Swift

    public init(
        logSuccess: Bool = false,
        logFailures: Bool = true,
        logCancelledRequests: Bool = false
        )
  • Called, when response was successfully parsed. If logSuccess property has been turned on, prints cURL representation of request.

    Declaration

    Swift

    open func didSuccessfullyParseResponse<Model, ErrorModel>(_ response: (URLRequest?, HTTPURLResponse?, Data?, Error?), creating result: Model, forRequest request: Request, formedFrom tronRequest: BaseRequest<Model, ErrorModel>)
  • Called, when request received error. If logFailures has been turned on, prints cURL representation of request and helpful debugging information such as status code, HTTP body contents and error message. If logCancelledRequests property is turned to true, they are also printed.

    Declaration

    Swift

    open func didReceiveError<Model, ErrorModel>(_ error: ErrorModel, forResponse response: (URLRequest?, HTTPURLResponse?, Data?, Error?), request: Request, formedFrom tronRequest: BaseRequest<Model, ErrorModel>) where ErrorModel : ErrorSerializable