Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
signal
traffic-signal-platform
Commits
a56798c3
Commit
a56798c3
authored
Feb 28, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 通用日志处理逻辑注释优化
parent
cf84f448
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
LogAspectHandler.java
...java/net/wanji/common/framework/log/LogAspectHandler.java
+7
-8
No files found.
wj-common/src/main/java/net/wanji/common/framework/log/LogAspectHandler.java
View file @
a56798c3
...
...
@@ -46,7 +46,7 @@ public class LogAspectHandler {
}
/**
* 执行切点controller之前执行的逻辑
* 执行切点controller之前执行的逻辑
:打印请求日志
*
* @param joinPoint
*/
...
...
@@ -56,7 +56,6 @@ public class LogAspectHandler {
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
String
ip
=
IpAddressUtil
.
getIpAddress
(
request
);
Map
<
String
,
String
>
map
=
getControllerMethodDescription
(
joinPoint
);
//*========操作日志=========*//
OperateLog
log
=
new
OperateLog
();
log
.
setDescription
(
map
.
get
(
"description"
).
toString
());
log
.
setIp
(
ip
);
...
...
@@ -68,12 +67,13 @@ public class LogAspectHandler {
//打印操作日志
this
.
consoleLog
(
log
,
request
);
}
catch
(
Exception
e
)
{
log
.
error
(
"
日志切面直行前
异常,异常信息: {}"
,
e
);
log
.
error
(
"
打印日志信息日志切面执行
异常,异常信息: {}"
,
e
);
}
}
/**
* MVC返回结果处理逻辑
* MVC返回结果处理逻辑,打印请求信息和结果信息
* todo 后续可增加日志流水表,插入流水表中
*
* @param joinPoint
* @param jsonViewObject
...
...
@@ -89,7 +89,6 @@ public class LogAspectHandler {
String
uri
=
request
.
getRequestURL
().
toString
();
//获取信息
Map
<
String
,
String
>
map
=
getControllerMethodDescription
(
joinPoint
);
//*========操作日志=========*//
OperateLog
operateLog
=
new
OperateLog
();
operateLog
.
setDescription
(
map
.
get
(
"description"
).
toString
());
operateLog
.
setIp
(
ip
);
...
...
@@ -97,10 +96,10 @@ public class LogAspectHandler {
operateLog
.
setOperationType
(
map
.
get
(
"operationType"
).
toString
());
operateLog
.
setUrl
(
request
.
getRequestURL
().
toString
());
operateLog
.
setArgs
(
getArgs
(
request
,
joinPoint
));
operateLog
.
setStatus
(
jsonViewObject
.
getStatus
(
));
operateLog
.
setStatus
(
String
.
valueOf
(
jsonViewObject
.
getCode
()
));
operateLog
.
setResult
(
JSON
.
toJSONString
(
jsonViewObject
));
operateLog
.
setCreateTime
(
new
Date
());
log
.
info
(
"\n外部系统调用本地接口,请求IP = {} || 接口 = {} || 地址 = {} || 响应状态 = {}"
,
ip
,
map
.
get
(
"description"
).
toString
(),
uri
,
jsonViewObject
.
get
Status
());
log
.
info
(
"\n外部系统调用本地接口,请求IP = {} || 接口 = {} || 地址 = {} || 响应状态 = {}"
,
ip
,
map
.
get
(
"description"
).
toString
(),
uri
,
jsonViewObject
.
get
Code
());
}
catch
(
Exception
e
)
{
//记录本地异常日志
log
.
error
(
"记录本地接口响应日志异常,异常信息:{}"
,
e
);
...
...
@@ -174,7 +173,7 @@ public class LogAspectHandler {
}
/**
* 获取@Aspect
标注的controller方法
* 获取@Aspect
Log标注的controller方法注解信息
*
* @param joinPoint
* @return
...
...
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