DebugLogging class

Dio interceptor that records every request in DebugStorage and prints it to the console in debug mode.

Usually added with dio.addDebugLogger(); adding it directly also works:

dio.interceptors.add(DebugLogging());

Disabled in release builds unless enabled is set: a disabled interceptor passes requests through without recording or changing them.

Constructors

DebugLogging({bool enabled = kDebugMode, bool printToConsole = kDebugMode, bool redactSensitiveHeaders = true, int maxConsoleBodyLength = 2000, List<DebugEnvironment> environments = const [], Dio? client})

Properties

client → Dio?
The Dio this interceptor belongs to. "Retry" resends with it, so certificate pinning and other settings are kept.
final
debug → DebugStorage
final
enabled → bool
Whether requests are recorded. Defaults to false in release builds.
final
environments → List<DebugEnvironment>
Backends this Dio can be switched to from the log page. When empty, the list from DioDebugLogger.setEnvironments is used.
final
hashCode → int
The hash code for this object.
no setterinherited
maxConsoleBodyLength → int
Maximum body length printed to the console.
final
printToConsole → bool
Whether to print to the console.
final
redactSensitiveHeaders → bool
Whether secrets (passwords, tokens, keys…) are masked in the console, in headers, bodies and URLs.
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(DioException err, ErrorInterceptorHandler handler) → void
Called when an exception was occurred during the request.
onRequest(RequestOptions options, RequestInterceptorHandler handler) → Future<void>
Called when the request is about to be sent.
onResponse(Response response, ResponseInterceptorHandler handler) → void
Called when the response is about to be resolved.
toString() → String
A string representation of this object.
inherited

Operators

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

Constants

clientKey → const String
Key under which client is stored in RequestOptions.extra.