Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
cloud-backend
Commits
3201f3e7
Commit
3201f3e7
authored
May 27, 2021
by
袁伟铭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.0.0
parent
30e248ca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
9 deletions
+9
-9
api-server/src/main/java/com/zq/api/controller/ApiController.java
+4
-4
api-server/src/main/java/com/zq/api/service/ApiService.java
+1
-1
common-utils/src/main/java/com/zq/common/entity/ApiLog.java
+3
-3
config/sql/init.sql
+1
-1
No files found.
api-server/src/main/java/com/zq/api/controller/ApiController.java
View file @
3201f3e7
...
...
@@ -73,13 +73,13 @@ public class ApiController {
form
.
setApiTokenVo
(
tokenVo
);
}
String
errorInfo
=
""
;
String
stackTrace
=
""
;
// 调用接口方法
ApiResp
resp
;
try
{
resp
=
apiService
.
action
(
form
);
}
catch
(
Exception
e
)
{
errorInfo
=
ThrowableUtil
.
getStackTrace
(
e
);
stackTrace
=
ThrowableUtil
.
getStackTrace
(
e
);
e
.
printStackTrace
();
// 判断指定异常是否来自或者包含指定异常
if
(
ExceptionUtil
.
isFromOrSuppressedThrowable
(
e
,
FeignException
.
Unauthorized
.
class
))
{
...
...
@@ -95,7 +95,7 @@ public class ApiController {
// 如果是500错误, 服务会返回错误的堆栈信息
if
(
resp
.
getCode
().
equals
(
ApiCodeEnum
.
SERVER_ERROR
.
code
()))
{
errorInfo
=
resp
.
getMsg
();
stackTrace
=
resp
.
getMsg
();
resp
.
setMsg
(
ApiCodeEnum
.
SERVER_ERROR
.
msg
());
}
...
...
@@ -107,7 +107,7 @@ public class ApiController {
}
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
;
}
...
...
api-server/src/main/java/com/zq/api/service/ApiService.java
View file @
3201f3e7
...
...
@@ -78,7 +78,7 @@ public class ApiService {
.
ip
(
ip
)
.
logType
(
logType
)
.
respMsg
(
respMsg
)
.
errorInfo
(
errorInfo
)
.
stackTrace
(
errorInfo
)
.
timeCost
(
timeCost
)
.
createTime
(
DateUtil
.
date
().
toJdkDate
())
.
build
());
...
...
common-utils/src/main/java/com/zq/common/entity/ApiLog.java
View file @
3201f3e7
...
...
@@ -80,10 +80,10 @@ public class ApiLog {
private
String
respMsg
;
/**
*
错误信息
*
堆栈跟踪
*/
@ApiModelProperty
(
"
错误信息
"
)
private
String
errorInfo
;
@ApiModelProperty
(
"
堆栈跟踪
"
)
private
String
stackTrace
;
/**
* 耗时-毫秒
...
...
config/sql/init.sql
View file @
3201f3e7
...
...
@@ -60,7 +60,7 @@ CREATE TABLE `t_api_log` (
`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
'日志类型'
,
`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
'耗时-毫秒'
,
`create_time`
datetime
(
0
)
NULL
DEFAULT
NULL
COMMENT
'创建时间'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment