Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
李墨
/
spring-boot-resilience4j-demo
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
97e0d49c
authored
2022-07-29 20:01:21 +0800
by
李墨
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[fix]:修复日志打印
1 parent
a0cfa949
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
src/main/java/com/seektruth/demo/spring/boot/resilience4j/aspect/OperateLogAspect.java
src/main/java/com/seektruth/demo/spring/boot/resilience4j/service/impl/BusinessServiceImpl.java
src/main/java/com/seektruth/demo/spring/boot/resilience4j/aspect/OperateLogAspect.java
View file @
97e0d49
...
...
@@ -35,11 +35,11 @@ public class OperateLogAspect implements Ordered {
String
className
=
joinPoint
.
getTarget
().
getClass
().
getName
();
String
methodName
=
joinPoint
.
getSignature
().
getName
();
Object
[]
args
=
joinPoint
.
getArgs
();
LOG
.
info
(
"========================================"
);
LOG
.
info
(
"
操作日志打印:
调用 {} {} 方法,请求参数:{}"
,
className
,
methodName
,
args
);
LOG
.
info
(
"==================
操作日志打印 start
======================"
);
LOG
.
info
(
"
\t
调用 {} {} 方法,请求参数:{}"
,
className
,
methodName
,
args
);
Object
result
=
joinPoint
.
proceed
(
args
);
LOG
.
info
(
"
操作日志打印:{} {} 方法,返回结果:{}"
,
result
);
LOG
.
info
(
"========================================"
);
LOG
.
info
(
"
\t{} {} 方法,返回结果:{}"
,
className
,
methodName
,
result
);
LOG
.
info
(
"==================
操作日志打印 end
======================"
);
return
result
;
}
...
...
src/main/java/com/seektruth/demo/spring/boot/resilience4j/service/impl/BusinessServiceImpl.java
View file @
97e0d49
package
com
.
seektruth
.
demo
.
spring
.
boot
.
resilience4j
.
service
.
impl
;
import
com.seektruth.demo.spring.boot.resilience4j.controller.BaseController
;
import
com.seektruth.demo.spring.boot.resilience4j.service.BusinessService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
java.util.concurrent.ThreadLocalRandom
;
...
...
@@ -12,6 +15,8 @@ import java.util.concurrent.TimeUnit;
@Service
public
class
BusinessServiceImpl
implements
BusinessService
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
BusinessServiceImpl
.
class
);
@Override
public
String
query
()
{
randomSleep
();
...
...
@@ -25,6 +30,6 @@ public class BusinessServiceImpl implements BusinessService {
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"当前业务处理时长:"
+
time
+
"秒"
);
LOG
.
info
(
"\t当前业务处理时长:{}秒"
,
time
);
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment