Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
88b98773
Commit
88b98773
authored
Aug 09, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
adcaf76f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
BaseRequestAspect.java
...ain/java/com/yanzuoguang/cloud/aop/BaseRequestAspect.java
+14
-4
FeignAspect.java
.../src/main/java/com/yanzuoguang/cloud/aop/FeignAspect.java
+3
-2
MqAspect.java
...oud/src/main/java/com/yanzuoguang/cloud/aop/MqAspect.java
+3
-2
WebAspect.java
...ud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
+3
-2
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/BaseRequestAspect.java
View file @
88b98773
...
@@ -123,19 +123,29 @@ public class BaseRequestAspect implements ThreadNext.Next {
...
@@ -123,19 +123,29 @@ public class BaseRequestAspect implements ThreadNext.Next {
return
paraJson
;
return
paraJson
;
}
}
/**
* 获取是否清空日志的标签
*
* @return 返回日志是否清空
*/
protected
boolean
requestLogInit
()
{
boolean
clear
=
Log
.
threadCurrent
()
==
null
;
if
(
clear
)
{
Log
.
threadBegin
();
}
return
clear
;
}
/**
/**
* 记录请求日志
* 记录请求日志
*
*
* @param joinPoint
* @param joinPoint
* @return
* @return
*/
*/
protected
long
requestLog
(
boolean
clear
,
String
tag
,
ProceedingJoinPoint
joinPoint
)
{
protected
long
requestLog
(
String
tag
,
ProceedingJoinPoint
joinPoint
)
{
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
try
{
try
{
String
name
=
joinPoint
.
getSignature
().
getName
();
String
name
=
joinPoint
.
getSignature
().
getName
();
if
(
clear
)
{
Log
.
threadBegin
();
}
Log
.
info
(
joinPoint
.
getSignature
().
getDeclaringType
(),
" %s [ %s ] request: %s"
,
Log
.
info
(
joinPoint
.
getSignature
().
getDeclaringType
(),
" %s [ %s ] request: %s"
,
tag
,
name
,
this
.
getMaxString
(
JsonHelper
.
serialize
(
joinPoint
.
getArgs
())));
tag
,
name
,
this
.
getMaxString
(
JsonHelper
.
serialize
(
joinPoint
.
getArgs
())));
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/FeignAspect.java
View file @
88b98773
...
@@ -37,7 +37,8 @@ public class FeignAspect extends BaseRequestAspect {
...
@@ -37,7 +37,8 @@ public class FeignAspect extends BaseRequestAspect {
*/
*/
@Around
(
value
=
"feignAspect()"
)
@Around
(
value
=
"feignAspect()"
)
public
Object
requestFeignAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
public
Object
requestFeignAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
long
start
=
requestLog
(
false
,
TAG
,
joinPoint
);
boolean
clear
=
requestLogInit
();
long
start
=
requestLog
(
TAG
,
joinPoint
);
Object
result
=
null
;
Object
result
=
null
;
Exception
ex
=
null
;
Exception
ex
=
null
;
...
@@ -61,7 +62,7 @@ public class FeignAspect extends BaseRequestAspect {
...
@@ -61,7 +62,7 @@ public class FeignAspect extends BaseRequestAspect {
ex
=
e
;
ex
=
e
;
throw
e
;
throw
e
;
}
finally
{
}
finally
{
responseLog
(
false
,
TAG
,
StringHelper
.
EMPTY
,
joinPoint
,
start
,
result
,
ex
);
responseLog
(
clear
,
TAG
,
StringHelper
.
EMPTY
,
joinPoint
,
start
,
result
,
ex
);
}
}
}
}
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/MqAspect.java
View file @
88b98773
...
@@ -35,7 +35,8 @@ public class MqAspect extends BaseRequestAspect {
...
@@ -35,7 +35,8 @@ public class MqAspect extends BaseRequestAspect {
*/
*/
@Around
(
value
=
"mqAspect()"
)
@Around
(
value
=
"mqAspect()"
)
public
Object
requestWebAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
public
Object
requestWebAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
long
start
=
requestLog
(
true
,
TAG
,
joinPoint
);
boolean
clear
=
requestLogInit
();
long
start
=
requestLog
(
TAG
,
joinPoint
);
Object
result
=
null
;
Object
result
=
null
;
Exception
ex
=
null
;
Exception
ex
=
null
;
try
{
try
{
...
@@ -47,7 +48,7 @@ public class MqAspect extends BaseRequestAspect {
...
@@ -47,7 +48,7 @@ public class MqAspect extends BaseRequestAspect {
ex
=
e
;
ex
=
e
;
throw
e
;
throw
e
;
}
finally
{
}
finally
{
responseLog
(
true
,
TAG
,
StringHelper
.
EMPTY
,
joinPoint
,
start
,
result
,
ex
);
responseLog
(
clear
,
TAG
,
StringHelper
.
EMPTY
,
joinPoint
,
start
,
result
,
ex
);
}
}
}
}
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
View file @
88b98773
...
@@ -57,8 +57,9 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -57,8 +57,9 @@ public class WebAspect extends BaseRequestAspect {
*/
*/
@Around
(
value
=
"webAspect()"
)
@Around
(
value
=
"webAspect()"
)
public
Object
requestWebAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
public
Object
requestWebAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
boolean
clear
=
requestLogInit
();
// 用户数据库记录
// 用户数据库记录
long
start
=
requestLog
(
true
,
TAG
,
joinPoint
);
long
start
=
requestLog
(
TAG
,
joinPoint
);
Object
result
=
null
;
Object
result
=
null
;
Exception
ex
=
null
;
Exception
ex
=
null
;
Ref
<
Boolean
>
flag
=
new
Ref
<>(
false
);
Ref
<
Boolean
>
flag
=
new
Ref
<>(
false
);
...
@@ -84,7 +85,7 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -84,7 +85,7 @@ public class WebAspect extends BaseRequestAspect {
if
(!
isGateWay
)
{
if
(!
isGateWay
)
{
tokenFinish
(
flag
);
tokenFinish
(
flag
);
}
}
responseLog
(
true
,
TAG
,
HttpAspectUtil
.
getHttpRequestUrl
(),
joinPoint
,
start
,
result
,
ex
);
responseLog
(
clear
,
TAG
,
HttpAspectUtil
.
getHttpRequestUrl
(),
joinPoint
,
start
,
result
,
ex
);
}
}
}
}
...
...
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