Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
U
unififi-spring-cloud-guide
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
lihaipeng
unififi-spring-cloud-guide
Commits
8c46b10a
Commit
8c46b10a
authored
Jul 22, 2020
by
lihaipeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
403b95ef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
11 deletions
+11
-11
pom.xml
unififi-demo1-service/pom.xml
+1
-1
ControllerLogAspect.java
...va/com/unififi/config/controller/ControllerLogAspect.java
+5
-5
UnififiFeignLogger.java
...ain/java/com/unififi/config/feign/UnififiFeignLogger.java
+2
-2
RestTemplateLogInterceptor.java
...a/com/unififi/config/rest/RestTemplateLogInterceptor.java
+2
-2
pom.xml
unififi-demo2-service/pom.xml
+1
-1
No files found.
unififi-demo1-service/pom.xml
View file @
8c46b10a
...
...
@@ -41,7 +41,7 @@
<dependency>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-client
</artifactId>
<version>
1.3.
1
</version>
<version>
1.3.
0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
unififi-demo1-service/src/main/java/com/unififi/config/controller/ControllerLogAspect.java
View file @
8c46b10a
...
...
@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
@Aspect
@Component
public
class
ControllerLogAspect
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
"Controller
Aspect
Log"
);
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
"ControllerLog"
);
@Autowired
private
UnififiProperties
unififiProperties
;
...
...
@@ -44,7 +44,7 @@ public class ControllerLogAspect {
}
if
(
logger
.
isInfoEnabled
()
&&
unififiProperties
.
getLogger
().
getController
().
isEnabled
())
{
if
(!
unififiProperties
.
getLogger
().
getController
().
getSkipMethodSigns
().
contains
(
pjp
.
getSignature
().
toShortString
()))
{
logger
.
info
(
"U
nififi
-REQ-[{}] {}"
,
pjp
.
getSignature
().
toShortString
(),
(
requestData
!=
null
?
requestData
:
""
));
logger
.
info
(
"U
NIFIFI
-REQ-[{}] {}"
,
pjp
.
getSignature
().
toShortString
(),
(
requestData
!=
null
?
requestData
:
""
));
}
}
Object
result
=
pjp
.
proceed
();
...
...
@@ -56,16 +56,16 @@ public class ControllerLogAspect {
if
(
logger
.
isInfoEnabled
()
&&
unififiProperties
.
getLogger
().
getController
().
isEnabled
())
{
if
(!
unififiProperties
.
getLogger
().
getController
().
getSkipMethodSigns
().
contains
(
pjp
.
getSignature
().
toShortString
()))
{
if
(
unififiProperties
.
getLogger
().
getController
().
getIgnoreResponseDataMethodSigns
().
contains
(
pjp
.
getSignature
().
toShortString
()))
{
logger
.
info
(
"U
nififi
-RESP-[{}] IGNORE_DATA size:{} spend:{}ms"
,
pjp
.
getSignature
().
toShortString
(),
(
responseData
!=
null
?
responseData
.
length
()
:
0
),
elapsedTime
);
logger
.
info
(
"U
NIFIFI
-RESP-[{}] IGNORE_DATA size:{} spend:{}ms"
,
pjp
.
getSignature
().
toShortString
(),
(
responseData
!=
null
?
responseData
.
length
()
:
0
),
elapsedTime
);
}
else
{
logger
.
info
(
"U
nififi
-RESP-[{}] {} size:{} spend:{}ms"
,
pjp
.
getSignature
().
toShortString
(),
(
responseData
!=
null
?
responseData
:
""
),
(
responseData
!=
null
?
responseData
.
length
()
:
0
),
elapsedTime
);
logger
.
info
(
"U
NIFIFI
-RESP-[{}] {} size:{} spend:{}ms"
,
pjp
.
getSignature
().
toShortString
(),
(
responseData
!=
null
?
responseData
:
""
),
(
responseData
!=
null
?
responseData
.
length
()
:
0
),
elapsedTime
);
}
}
}
return
result
;
}
catch
(
Throwable
throwable
)
{
if
(
logger
.
isErrorEnabled
()
&&
unififiProperties
.
getLogger
().
getController
().
isEnabled
())
{
logger
.
error
(
"U
nififi-RESP-[{}] {}:
{}"
,
pjp
.
getSignature
().
toShortString
(),
throwable
.
getClass
().
getSimpleName
(),
throwable
.
getMessage
());
logger
.
error
(
"U
NIFIFI-RESP-[{}] [{}]
{}"
,
pjp
.
getSignature
().
toShortString
(),
throwable
.
getClass
().
getSimpleName
(),
throwable
.
getMessage
());
}
return
throwable
;
}
...
...
unififi-demo1-service/src/main/java/com/unififi/config/feign/UnififiFeignLogger.java
View file @
8c46b10a
...
...
@@ -26,7 +26,7 @@ public class UnififiFeignLogger extends feign.Logger {
protected
void
logRequest
(
String
configKey
,
Level
logLevel
,
Request
request
)
{
if
(
logger
.
isInfoEnabled
()
&&
setting
.
isEnabled
())
{
if
(!
setting
.
getSkipMethodSigns
().
contains
(
configKey
))
{
logger
.
info
(
"FEIGN-REQ-[{}] {}
-->
{} {}"
,
configKey
,
request
.
body
()
!=
null
?
new
String
(
request
.
body
(),
Charsets
.
UTF_8
)
:
""
,
request
.
httpMethod
(),
request
.
url
());
logger
.
info
(
"FEIGN-REQ-[{}] {}
-->
{} {}"
,
configKey
,
request
.
body
()
!=
null
?
new
String
(
request
.
body
(),
Charsets
.
UTF_8
)
:
""
,
request
.
httpMethod
(),
request
.
url
());
}
}
}
...
...
@@ -58,7 +58,7 @@ public class UnififiFeignLogger extends feign.Logger {
@Override
protected
IOException
logIOException
(
String
configKey
,
Level
logLevel
,
IOException
ioe
,
long
elapsedTime
)
{
if
(
logger
.
isErrorEnabled
()
&&
setting
.
isEnabled
())
{
logger
.
error
(
"FEIGN-RESP-[{}]
{}:
{}"
,
configKey
,
ioe
.
getClass
().
getSimpleName
(),
ioe
.
getMessage
());
logger
.
error
(
"FEIGN-RESP-[{}]
[{}]
{}"
,
configKey
,
ioe
.
getClass
().
getSimpleName
(),
ioe
.
getMessage
());
}
return
ioe
;
}
...
...
unififi-demo1-service/src/main/java/com/unififi/config/rest/RestTemplateLogInterceptor.java
View file @
8c46b10a
...
...
@@ -30,7 +30,7 @@ public class RestTemplateLogInterceptor implements ClientHttpRequestInterceptor
if
(
logger
.
isInfoEnabled
()
&&
setting
.
isEnabled
())
{
if
(!
setting
.
getSkipMethodSigns
().
contains
(
methodTag
))
{
logger
.
info
(
"REST-REQ-[{}] {}
-->
{} {}"
,
methodTag
,
body
!=
null
?
new
String
(
body
,
Charsets
.
UTF_8
)
:
""
,
request
.
getMethod
(),
request
.
getURI
());
logger
.
info
(
"REST-REQ-[{}] {}
-->
{} {}"
,
methodTag
,
body
!=
null
?
new
String
(
body
,
Charsets
.
UTF_8
)
:
""
,
request
.
getMethod
(),
request
.
getURI
());
}
}
long
start
=
System
.
nanoTime
();
...
...
@@ -63,7 +63,7 @@ public class RestTemplateLogInterceptor implements ClientHttpRequestInterceptor
}
}
catch
(
IOException
ioe
)
{
if
(
logger
.
isErrorEnabled
()
&&
setting
.
isEnabled
())
{
logger
.
error
(
"REST-RESP-[{}]
{}:
{}"
,
methodTag
,
ioe
.
getClass
().
getSimpleName
(),
ioe
.
getMessage
());
logger
.
error
(
"REST-RESP-[{}]
[{}]
{}"
,
methodTag
,
ioe
.
getClass
().
getSimpleName
(),
ioe
.
getMessage
());
}
throw
ioe
;
}
...
...
unififi-demo2-service/pom.xml
View file @
8c46b10a
...
...
@@ -38,7 +38,7 @@
<dependency>
<groupId>
com.alibaba.nacos
</groupId>
<artifactId>
nacos-client
</artifactId>
<version>
1.3.
1
</version>
<version>
1.3.
0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
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