Skip to content

Commit

Permalink
1、update dio 5.0.0 2、fix DioLogInterceptor
Browse files Browse the repository at this point in the history
1、update dio 5.0.0
2、fix DioLogInterceptor
  • Loading branch information
yfming93 committed May 8, 2023
1 parent 30f29bc commit 3e66fae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .dart_tool/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1
3.7.12
2 changes: 2 additions & 0 deletions android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sdk.dir=/Users/mingo/Library/Android/sdk
flutter.sdk=/Users/mingo/Downloads/flutter
18 changes: 10 additions & 8 deletions lib/interceptor/dio_log_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:dio_log/bean/err_options.dart';
import 'package:dio_log/bean/net_options.dart';
import 'package:dio_log/bean/req_options.dart';
import 'package:dio_log/bean/res_options.dart';
// import 'package:flutter/material.dart' show debugPrint;
import 'dart:developer';

import '../dio_log.dart';

Expand Down Expand Up @@ -62,14 +64,14 @@ class DioLogInterceptor implements Interceptor {
resOpt.headers = response.headers.map;
logManage?.onResponse(resOpt);
if (enablePrintLog) {
NetOptions log =
LogPoolManager.getInstance().logMap[resOpt.id.toString()]!;
print('dio_log: request: url:${log.reqOptions?.url}');
print('dio_log: request: method:${log.reqOptions?.method}');
print('dio_log: request: params:${log.reqOptions?.params}');
print(
'dio_log: request: duration:${getTimeStr1(log.reqOptions!.requestTime!)}');
print('dio_log: response: ${toJson(log.resOptions?.data)}');
NetOptions opt = LogPoolManager.getInstance().logMap[resOpt.id.toString()]!;
log('dio_log_request: duration:${getTimeStr1(opt.reqOptions!.requestTime!)}');
log('dio_log_request: url:${opt.reqOptions?.url}');
log('dio_log_request: method:${opt.reqOptions?.method}');
log('dio_log_request: headers:${opt.reqOptions?.headers}');
log('dio_log_request: params:${opt.reqOptions?.params}');
log('dio_log_request: data:${opt.reqOptions?.data}');
log('dio_log_response: ${toJson(opt.resOptions?.data)}');
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
dependencies:
flutter:
sdk: flutter
dio: ^4.0.0
dio: any

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 3e66fae

Please sign in to comment.