From 988f19c94a601f6d07dc6d68628a97ec46458696 Mon Sep 17 00:00:00 2001 From: Fleeming Date: Fri, 23 Dec 2022 16:57:25 +0800 Subject: [PATCH] Update dio_log_interceptor.dart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、add reqOptions data params 2、exchange the print to log --- lib/interceptor/dio_log_interceptor.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/interceptor/dio_log_interceptor.dart b/lib/interceptor/dio_log_interceptor.dart index 1e1c230..f71d92d 100644 --- a/lib/interceptor/dio_log_interceptor.dart +++ b/lib/interceptor/dio_log_interceptor.dart @@ -3,8 +3,9 @@ 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 'dart:developer'; import '../dio_log.dart'; +import 'package:flutter/foundation.dart'; ///log日志的处理类 class DioLogInterceptor implements Interceptor { @@ -62,14 +63,14 @@ class DioLogInterceptor implements Interceptor { resOpt.headers = response.headers.map; logManage?.onResponse(resOpt); if (enablePrintLog) { - NetOptions log = + NetOptions logNp = 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)}'); + log('request: url:${logNp.reqOptions?.url}'); + log('request: method:${logNp.reqOptions?.method}'); + log('request: params:${logNp.reqOptions?.params}'); + log('request: data:${logNp.reqOptions?.data}'); + log('request: duration:${getTimeStr1(logNp.reqOptions!.requestTime!)}'); + log('response: ${toJson(logNp.resOptions?.data)}'); } } }