LoggingInterceptor

class LoggingInterceptor(level: LoggingInterceptor.Level, log: (String) -> Unit = { println(it) }) : HttpInterceptor

An interceptor that logs requests and responses.

Parameters

level

the level of logging. Caution: when uploading files, setting this to Level.BODY will cause the files to be fully loaded into memory, which may cause OutOfMemoryErrors.

log

a callback that gets called with a line of log. Contains headers and/or body. No attempt is made at detecting binary bodies. Do use Level.BODY with binary content

Constructors

Link copied to clipboard
constructor(level: LoggingInterceptor.Level, log: (String) -> Unit = { println(it) })
constructor(log: (String) -> Unit = { println(it) })

Types

Link copied to clipboard

Functions

Link copied to clipboard
open fun dispose()
Link copied to clipboard
open suspend override fun intercept(request: HttpRequest, chain: HttpInterceptorChain): HttpResponse

Intercepts the request and returns a response. Implementation may throw in case of error. Those errors are typically caught by the network transport and subsequently exposed in ApolloResponse.exception. If the exception is not an instance of ApolloException, it will be wrapped in an instance of ApolloNetworkException.