-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not an issue, just a question #3
Comments
You can listen to network events stream - Here's a logging interceptor I've used for one of our projects, you can either re-use it or slightly modify for your needs. /// Verbosely logs HTTP request and response metadata and any errors ocurred
/// during the operation
class DioLoggerInterceptor extends Interceptor {
final _log = Logger('Dio');
String _requestUrl(RequestOptions options) {
return '${options.uri}';
}
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
_log.fine('---> ${options.method} ${_requestUrl(options)}');
super.onRequest(options, handler);
}
@override
void onResponse(Response response, ResponseInterceptorHandler handler) {
_log.fine(
'<--- ${response.requestOptions.method} '
'${_requestUrl(response.requestOptions)} '
'[${response.statusCode}]',
);
super.onResponse(response, handler);
}
@override
void onError(DioError err, ErrorInterceptorHandler handler) {
_log.shout(
'-!!!- ${err.requestOptions.method} ${_requestUrl(err.requestOptions)} '
'[${err.response?.statusCode ?? -1}]',
);
// Ignore authentication errors because those errors might ocurr when token
// expires which will be refreshed automatically and request will be sent
// again.
if (err.response?.statusCode != 401)
_log.shout(err.message, err, err.stackTrace);
super.onError(err, handler);
}
} PS: |
Thankyou |
is there anyway to print all this data in log?
The text was updated successfully, but these errors were encountered: