Commit 3201f3e7 by 袁伟铭

1.0.0

parent 30e248ca
...@@ -73,13 +73,13 @@ public class ApiController { ...@@ -73,13 +73,13 @@ public class ApiController {
form.setApiTokenVo(tokenVo); form.setApiTokenVo(tokenVo);
} }
String errorInfo = ""; String stackTrace = "";
// 调用接口方法 // 调用接口方法
ApiResp resp; ApiResp resp;
try { try {
resp = apiService.action(form); resp = apiService.action(form);
} catch (Exception e) { } catch (Exception e) {
errorInfo = ThrowableUtil.getStackTrace(e); stackTrace = ThrowableUtil.getStackTrace(e);
e.printStackTrace(); e.printStackTrace();
// 判断指定异常是否来自或者包含指定异常 // 判断指定异常是否来自或者包含指定异常
if (ExceptionUtil.isFromOrSuppressedThrowable(e, FeignException.Unauthorized.class)) { if (ExceptionUtil.isFromOrSuppressedThrowable(e, FeignException.Unauthorized.class)) {
...@@ -95,7 +95,7 @@ public class ApiController { ...@@ -95,7 +95,7 @@ public class ApiController {
// 如果是500错误, 服务会返回错误的堆栈信息 // 如果是500错误, 服务会返回错误的堆栈信息
if (resp.getCode().equals(ApiCodeEnum.SERVER_ERROR.code())) { if (resp.getCode().equals(ApiCodeEnum.SERVER_ERROR.code())) {
errorInfo = resp.getMsg(); stackTrace = resp.getMsg();
resp.setMsg(ApiCodeEnum.SERVER_ERROR.msg()); resp.setMsg(ApiCodeEnum.SERVER_ERROR.msg());
} }
...@@ -107,7 +107,7 @@ public class ApiController { ...@@ -107,7 +107,7 @@ public class ApiController {
} }
String clientIP = ServletUtil.getClientIP(request); String clientIP = ServletUtil.getClientIP(request);
apiService.addLog(form, clientIP, logType, resp.getMsg(), errorInfo, System.currentTimeMillis() - start); apiService.addLog(form, clientIP, logType, resp.getMsg(), stackTrace, System.currentTimeMillis() - start);
return resp; return resp;
} }
......
...@@ -78,7 +78,7 @@ public class ApiService { ...@@ -78,7 +78,7 @@ public class ApiService {
.ip(ip) .ip(ip)
.logType(logType) .logType(logType)
.respMsg(respMsg) .respMsg(respMsg)
.errorInfo(errorInfo) .stackTrace(errorInfo)
.timeCost(timeCost) .timeCost(timeCost)
.createTime(DateUtil.date().toJdkDate()) .createTime(DateUtil.date().toJdkDate())
.build()); .build());
......
...@@ -80,10 +80,10 @@ public class ApiLog { ...@@ -80,10 +80,10 @@ public class ApiLog {
private String respMsg; private String respMsg;
/** /**
* 错误信息 * 堆栈跟踪
*/ */
@ApiModelProperty("错误信息") @ApiModelProperty("堆栈跟踪")
private String errorInfo; private String stackTrace;
/** /**
* 耗时-毫秒 * 耗时-毫秒
......
...@@ -60,7 +60,7 @@ CREATE TABLE `t_api_log` ( ...@@ -60,7 +60,7 @@ CREATE TABLE `t_api_log` (
`ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT 'IP', `ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT 'IP',
`log_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '日志类型', `log_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '日志类型',
`resp_msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '响应信息', `resp_msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '响应信息',
`error_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '错误信息', `stack_trace` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '堆栈跟踪',
`time_cost` bigint(20) NULL DEFAULT 0 COMMENT '耗时-毫秒', `time_cost` bigint(20) NULL DEFAULT 0 COMMENT '耗时-毫秒',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment