fix:修复网络请求异常时,api日志记录不完整的bug

This commit is contained in:
曾文豪
2024-09-14 22:57:03 +08:00
parent 278429157a
commit a816acaddb
2 changed files with 7 additions and 1 deletions

View File

@@ -84,6 +84,9 @@ public class TestController {
String jsonString = JSON.toJSONString(jsonTest);
LogFactory.get().info(jsonString);
String s = OkHttpUtil.get("http://toolbox.tieshengkeji.com/test/login/23232/3232");
LogFactory.get().info(s);
// ArrayList<String> strings = CollUtil.newArrayList("11111", "22222");
// coreLogService.addProcess("fdfd", strings, new ProcessImportConsumer<String>() {
// @Override

View File

@@ -14,7 +14,7 @@ import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
@Component
public class LogApiOkHttpInterceptor implements Interceptor {
public class OkHttpLogInterceptor implements Interceptor {
@Resource
CoreLogApiMapper coreLogApiMapper;
@@ -52,6 +52,9 @@ public class LogApiOkHttpInterceptor implements Interceptor {
response = new Response.Builder()
.request(request)
.protocol(Protocol.HTTP_1_1)
.code(logApi.getResult())
.message(e.getMessage())
.body(OkHttpUtil.ofJsonResponse(logApi.getRespBody()))
.build();
}