日志初始配置添加自定义标签

This commit is contained in:
2025-09-09 15:32:40 +08:00
parent 2d46fcaec3
commit 8076acc373
4 changed files with 25 additions and 13 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:EasyDartModule/base/logger/Logger.dart';
import 'package:dio/dio.dart';
import 'package:shelf/shelf.dart' as sf;
@@ -41,8 +43,11 @@ class TraceDio {
options.headers['X-Span-ID'] = spanId;
}
// 记录请求日志
_logger?.info('发送请求: ${options.method} ${options.uri}',
tag: "DIO", traceId: traceId, spanId: spanId);
_logger?.info(
'发送请求: ${options.method} ${options.uri} ${options.data != null ? jsonEncode(options.data) : ""}',
tag: "DIO",
traceId: traceId,
spanId: spanId);
return handler.next(options); // 继续请求
},
onResponse: (response, handler) {