LoggingInterceptor class

An interceptor that logs HTTP requests and responses.

Inheritance

Constructors

LoggingInterceptor({bool logRequest = true, bool logRequestHeaders = false, bool logRequestBody = true, bool logResponse = true, bool logResponseHeaders = false, bool logResponseBody = true, int maxBodyLength = 1000, bool prettyPrintJson = true, void logger(String message)?})

Properties

hashCode → int
The hash code for this object.
no setterinherited
logger → void Function(String message)?
Custom log function. If null, uses dart:developer log.
final
logRequest → bool
Whether to log request details.
final
logRequestBody → bool
Whether to log request body.
final
logRequestHeaders → bool
Whether to log request headers.
final
logResponse → bool
Whether to log response details.
final
logResponseBody → bool
Whether to log response body.
final
logResponseHeaders → bool
Whether to log response headers.
final
maxBodyLength → int
Maximum length of body to log (to avoid huge logs).
final
prettyPrintJson → bool
Whether to pretty print JSON bodies.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(ClientRequest request, Object error, int attemptCount) → Future<bool>
Called when an error occurs. Return true to retry the request, false to propagate the error.
override
onRequest(ClientRequest request) → Future<ClientRequest?>
Called before the request is sent. Return the modified request, or null to cancel the request.
override
onResponse(ClientRequest request, ClientResponse response) → Future<ClientResponse>
Called after the response is received. Return the modified response.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited