admin管理员组文章数量:1125455
I am using dio for networking and pretty_dio_logger for logging API requests and responses. My NetworkService code is as follows
this is my current dependencies.
dependencies:
dio: ^5.5.0+1
pretty_dio_logger: ^1.3.1
And this code is my network service for api calls.
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:gpace_app/core/network/authorization_interceptor.dart';
import 'package:gpace_app/flavors.dart';
import 'package:gpace_app/services/logger_service.dart';
import 'package:intl/intl.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
class NetworkService {
NetworkService(
this._dio,
) {
final intl = Intl();
_dio.options.baseUrl = F.baseUrl;
_dio.options.contentType = 'application/json';
_dio.options.headers = {
'lang': intl.locale,
'timeOffset': 0,
};
_dio.options.connectTimeout = const Duration(seconds: 20);
_dio.options.receiveTimeout = const Duration(seconds: 20);
_dio.options.validateStatus = (status) {
return status! < 500;
};
_dio.interceptors.add(AuthorizationInterceptor());
_dio.interceptors.add(
PrettyDioLogger(
responseBody: true,
requestBody: true,
responseHeader: false,
),
);
_dio.interceptors.add(
InterceptorsWrapper(
onRequest: (options, handler) {
handler.next(options);
},
onResponse: (response, handler) async {
handler.next(response);
},
onError: (DioException error, handler) {
if (error.response != null) {
handler.resolve(
Response(
requestOptions: error.requestOptions,
statusCode: error.response!.statusCode,
data: error.response!.data,
headers: error.response!.headers,
statusMessage: error.message,
),
);
} else {
handler.next(error);
}
},
),
);
}
final Dio _dio;
Future<Response<T>> get<T>(
String path, {
Map<String, dynamic>? queryParameters,
Options? options,
}) async {
try {
return await _dio.get<T>(
path,
queryParameters: queryParameters,
options: options,
);
} on DioException catch (e) {
_logError(e);
rethrow;
}
}
void _logError(DioException error) {
LoggerService.logError(
'DioError: ${error.message}',
);
if (error.response != null) {
LoggerService.logError('DioError Response: ${error.response?.data}');
}
}
}
Also i tried to use dio.LogInterceptor and error is still persisted.
flutter: flutter: Recursion during print() call.Abort adding print() call as Breadcrumb.
this is the print statement. This lines prints instead of my api responses and requests.
omer@% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.1.1 24B91 darwin-arm64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.84.0)
[✓] Connected device (3 available)
! Error: Browsing on the local area network for Iphone 11 Omer. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Ömer’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
I am using dio for networking and pretty_dio_logger for logging API requests and responses. My NetworkService code is as follows
this is my current dependencies.
dependencies:
dio: ^5.5.0+1
pretty_dio_logger: ^1.3.1
And this code is my network service for api calls.
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:gpace_app/core/network/authorization_interceptor.dart';
import 'package:gpace_app/flavors.dart';
import 'package:gpace_app/services/logger_service.dart';
import 'package:intl/intl.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
class NetworkService {
NetworkService(
this._dio,
) {
final intl = Intl();
_dio.options.baseUrl = F.baseUrl;
_dio.options.contentType = 'application/json';
_dio.options.headers = {
'lang': intl.locale,
'timeOffset': 0,
};
_dio.options.connectTimeout = const Duration(seconds: 20);
_dio.options.receiveTimeout = const Duration(seconds: 20);
_dio.options.validateStatus = (status) {
return status! < 500;
};
_dio.interceptors.add(AuthorizationInterceptor());
_dio.interceptors.add(
PrettyDioLogger(
responseBody: true,
requestBody: true,
responseHeader: false,
),
);
_dio.interceptors.add(
InterceptorsWrapper(
onRequest: (options, handler) {
handler.next(options);
},
onResponse: (response, handler) async {
handler.next(response);
},
onError: (DioException error, handler) {
if (error.response != null) {
handler.resolve(
Response(
requestOptions: error.requestOptions,
statusCode: error.response!.statusCode,
data: error.response!.data,
headers: error.response!.headers,
statusMessage: error.message,
),
);
} else {
handler.next(error);
}
},
),
);
}
final Dio _dio;
Future<Response<T>> get<T>(
String path, {
Map<String, dynamic>? queryParameters,
Options? options,
}) async {
try {
return await _dio.get<T>(
path,
queryParameters: queryParameters,
options: options,
);
} on DioException catch (e) {
_logError(e);
rethrow;
}
}
void _logError(DioException error) {
LoggerService.logError(
'DioError: ${error.message}',
);
if (error.response != null) {
LoggerService.logError('DioError Response: ${error.response?.data}');
}
}
}
Also i tried to use dio.LogInterceptor and error is still persisted.
flutter: flutter: Recursion during print() call.Abort adding print() call as Breadcrumb.
this is the print statement. This lines prints instead of my api responses and requests.
omer@% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.1.1 24B91 darwin-arm64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.84.0)
[✓] Connected device (3 available)
! Error: Browsing on the local area network for Iphone 11 Omer. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Ömer’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
Share
Improve this question
asked Jan 9 at 6:48
Ömer Faruk GencÖmer Faruk Genc
1
New contributor
Ömer Faruk Genc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1 Answer
Reset to default 0I don't have enough reputation to comment.
Are you by any chance using Sentry? Sentry uses Breadcrumbs for their sort of "stack trace" feature.
When using Sentry, I also appear to get this issue due to OkHTTP logs being pretty printed out by pretty_dio_logger.
I am uncertain if Breadcrumbs are used in any other common libraries, but to me it seems largely like a Sentry construct.
本文标签:
版权声明:本文标题:dart - Flutter dio and pretty_dio_logger Error: "Recursion during print() call. Abort adding print() call as Breadcrumb 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736667768a1946755.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论