Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
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
order-group-application
order-group
Commits
aaa39a55
Commit
aaa39a55
authored
Jul 23, 2021
by
zhiheng.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除logutil 打印
parent
82f78c45
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
13 deletions
+11
-13
shopping-cart-application-service/src/main/java/cn/freemud/annotations/IgnoreFeignLogAnnotation.java
+1
-5
shopping-cart-application-service/src/main/java/cn/freemud/aop/WebAspect.java
+10
-8
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/annotations/IgnoreFeignLogAnnotation.java
View file @
aaa39a55
...
@@ -9,11 +9,7 @@ import java.lang.annotation.*;
...
@@ -9,11 +9,7 @@ import java.lang.annotation.*;
@Inherited
@Inherited
public
@interface
IgnoreFeignLogAnnotation
{
public
@interface
IgnoreFeignLogAnnotation
{
/**
boolean
printInfoLog
()
default
true
;
* 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印
* @return
*/
boolean
printLog
()
default
true
;
/**
/**
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
...
...
shopping-cart-application-service/src/main/java/cn/freemud/aop/WebAspect.java
View file @
aaa39a55
...
@@ -8,6 +8,8 @@ import cn.freemud.inteceptor.CommonServiceException;
...
@@ -8,6 +8,8 @@ import cn.freemud.inteceptor.CommonServiceException;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.utils.LogUtil
;
import
cn.freemud.utils.LogUtil
;
import
cn.freemud.utils.ResponseUtil
;
import
cn.freemud.utils.ResponseUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformConfig
;
import
com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformConfig
;
import
com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo
;
import
com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo
;
import
com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformConfigManager
;
import
com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformConfigManager
;
...
@@ -221,18 +223,17 @@ public class WebAspect {
...
@@ -221,18 +223,17 @@ public class WebAspect {
if
(
sig
instanceof
MethodSignature
)
{
if
(
sig
instanceof
MethodSignature
)
{
msig
=
(
MethodSignature
)
sig
;
msig
=
(
MethodSignature
)
sig
;
Method
currentMethod
=
sig
.
getDeclaringType
().
getDeclaredMethod
(
msig
.
getName
(),
msig
.
getParameterTypes
());
Method
currentMethod
=
sig
.
getDeclaringType
().
getDeclaredMethod
(
msig
.
getName
(),
msig
.
getParameterTypes
());
Object
logReult
=
result
;
Object
logReult
=
result
;
ThirdPartLogVo
thirdPartLogVo
=
LogUtil
.
createThirdPartLogVo
(
joinPoint
);
ThirdPartLogVo
thirdPartLogVo
=
LogUtil
.
createThirdPartLogVo
(
joinPoint
);
String
statusCodeValue
=
"ignore"
;
String
statusCodeValue
=
"ignore"
;
String
messageValue
=
"ignore"
;
String
messageValue
=
"ignore"
;
// 打印第三方出参日志
// 打印第三方出参日志 如果feign方法没有IgnoreFeignLogAnnotation注解,全部打日志,但是由于statusCodeValue = "ignore",是不是触发日志告警的
if
(!
this
.
printFeignResponseBodyLog
)
{
IgnoreFeignLogAnnotation
logIgnore
=
currentMethod
.
getAnnotation
(
IgnoreFeignLogAnnotation
.
class
);
IgnoreFeignLogAnnotation
logIgnore
=
currentMethod
.
getAnnotation
(
IgnoreFeignLogAnnotation
.
class
);
if
(
logIgnore
!=
null
&&
logIgnore
.
printLog
())
{
if
(
logIgnore
!=
null
)
{
statusCodeValue
=
org
.
apache
.
commons
.
beanutils
.
BeanUtils
.
getProperty
(
result
,
logIgnore
.
statusCodeFieldName
());
JSONObject
json
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
result
));
messageValue
=
org
.
apache
.
commons
.
beanutils
.
BeanUtils
.
getProperty
(
result
,
logIgnore
.
messageFieldName
());
statusCodeValue
=
json
.
getString
(
logIgnore
.
statusCodeFieldName
());
messageValue
=
json
.
getString
(
logIgnore
.
messageFieldName
());
if
(!
this
.
printFeignResponseBodyLog
&&
!
logIgnore
.
printInfoLog
())
{
//todo 当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
//todo 当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
String
[]
excludeStatusCodes
=
logIgnore
.
excludeStatusCodes
();
String
[]
excludeStatusCodes
=
logIgnore
.
excludeStatusCodes
();
if
(!
StringUtils
.
isEmpty
(
statusCodeValue
)
&&
this
.
containStatusCode
(
excludeStatusCodes
,
statusCodeValue
))
{
if
(!
StringUtils
.
isEmpty
(
statusCodeValue
)
&&
this
.
containStatusCode
(
excludeStatusCodes
,
statusCodeValue
))
{
...
@@ -242,7 +243,8 @@ public class WebAspect {
...
@@ -242,7 +243,8 @@ public class WebAspect {
}
}
}
}
}
}
ThirdPartyLog
.
infoConvertJson
(
statusCodeValue
,
messageValue
,
start
,
System
.
currentTimeMillis
(),
thirdPartLogVo
.
getUri
(),
thirdPartLogVo
.
getRequestBody
(),
logReult
);
ThirdPartyLog
.
infoConvertJson
(
statusCodeValue
,
messageValue
,
start
,
System
.
currentTimeMillis
(),
thirdPartLogVo
.
getUri
(),
thirdPartLogVo
.
getRequestBody
(),
logReult
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"WebAspect Feign Log Ignore error {}"
,
ExceptionUtils
.
getMessage
(
e
));
log
.
error
(
"WebAspect Feign Log Ignore error {}"
,
ExceptionUtils
.
getMessage
(
e
));
...
...
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