ApiLogOptions class

Controls what the console logger prints for each request.

The logger is only attached in non-release builds — in release nothing is logged regardless of what you set here.

Pass an instance to ApiServices.configure(logging: ...), or to ApiServices.setLogging(...) if you don't use token auth. The defaults match the package's previous behaviour: request line, request body, response body, and errors.

Example — quiet logs, headers only when debugging auth:

ApiServices.configure(
  getToken: () async => await storage.read(key: 'token'),
  onTokenRefresh: () async => await authRepo.refresh(),
  logging: const ApiLogOptions(
    requestBody: false,   // don't print passwords / PII
    requestHeader: true,  // but do show the Authorization header
    responseBody: false,  // responses are large
  ),
);

Example — silence logging entirely:

ApiServices.configure(
  getToken: () async => await storage.read(key: 'token'),
  onTokenRefresh: () async => await authRepo.refresh(),
  logging: const ApiLogOptions.disabled(),
);

Constructors

ApiLogOptions({bool enabled = true, bool request = true, bool requestHeader = false, bool requestBody = true, bool responseHeader = false, bool responseBody = true, bool error = true, int maxWidth = 90, bool compact = true, void logPrint(Object object)?})
const
ApiLogOptions.disabled()
No logging at all, even in debug builds.
const

Properties

compact → bool
Print JSON in compact form rather than one node per line.
final
enabled → bool
Master switch. When false no logger is attached at all and every other field is ignored.
final
error → bool
Print errors (DioExceptions, including non-2xx responses).
final
hashCode → int
The hash code for this object.
no setterinherited
logPrint → void Function(Object object)?
Where log lines go. Defaults to print.
final
maxWidth → int
Line width before the logger wraps. Defaults to 90 characters.
final
request → bool
Print the request line (method + URL).
final
requestBody → bool
Print the request body.
final
requestHeader → bool
Print request headers and query parameters.
final
responseBody → bool
Print the response body.
final
responseHeader → bool
Print response headers.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({bool? enabled, bool? request, bool? requestHeader, bool? requestBody, bool? responseHeader, bool? responseBody, bool? error, int? maxWidth, bool? compact, void logPrint(Object object)?}) → ApiLogOptions
Returns a copy with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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