Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
JAVA小学生-王铁柱
eladmin
提交
2d19ad49
E
eladmin
项目概览
JAVA小学生-王铁柱
/
eladmin
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
eladmin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2d19ad49
编写于
6月 03, 2019
作者:
Z
zhengjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
异步日志
上级
ec716f99
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
8 deletion
+6
-8
eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java
...n-logging/src/main/java/me/zhengjie/aspect/LogAspect.java
+3
-2
eladmin-logging/src/main/java/me/zhengjie/service/LogService.java
...logging/src/main/java/me/zhengjie/service/LogService.java
+1
-1
eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
...rc/main/java/me/zhengjie/service/impl/LogServiceImpl.java
+2
-5
未找到文件。
eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java
浏览文件 @
2d19ad49
...
...
@@ -6,6 +6,7 @@ import me.zhengjie.exception.BadRequestException;
import
me.zhengjie.service.LogService
;
import
me.zhengjie.utils.RequestHolder
;
import
me.zhengjie.utils.SecurityUtils
;
import
me.zhengjie.utils.StringUtils
;
import
me.zhengjie.utils.ThrowableUtil
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
...
...
@@ -51,7 +52,7 @@ public class LogAspect {
currentTime
=
System
.
currentTimeMillis
();
result
=
joinPoint
.
proceed
();
Log
log
=
new
Log
(
"INFO"
,
System
.
currentTimeMillis
()
-
currentTime
);
logService
.
save
(
getUsername
(),
RequestHolder
.
getHttpServletRequest
(
),
joinPoint
,
log
);
logService
.
save
(
getUsername
(),
StringUtils
.
getIP
(
RequestHolder
.
getHttpServletRequest
()
),
joinPoint
,
log
);
return
result
;
}
...
...
@@ -65,7 +66,7 @@ public class LogAspect {
public
void
logAfterThrowing
(
JoinPoint
joinPoint
,
Throwable
e
)
{
Log
log
=
new
Log
(
"ERROR"
,
System
.
currentTimeMillis
()
-
currentTime
);
log
.
setExceptionDetail
(
ThrowableUtil
.
getStackTrace
(
e
));
logService
.
save
(
getUsername
(),
RequestHolder
.
getHttpServletRequest
(
),
(
ProceedingJoinPoint
)
joinPoint
,
log
);
logService
.
save
(
getUsername
(),
StringUtils
.
getIP
(
RequestHolder
.
getHttpServletRequest
()
),
(
ProceedingJoinPoint
)
joinPoint
,
log
);
}
public
String
getUsername
()
{
...
...
eladmin-logging/src/main/java/me/zhengjie/service/LogService.java
浏览文件 @
2d19ad49
...
...
@@ -18,7 +18,7 @@ public interface LogService {
* @param log
*/
@Async
void
save
(
String
username
,
HttpServletRequest
request
,
ProceedingJoinPoint
joinPoint
,
Log
log
);
void
save
(
String
username
,
String
ip
,
ProceedingJoinPoint
joinPoint
,
Log
log
);
/**
* 查询异常详情
...
...
eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
浏览文件 @
2d19ad49
...
...
@@ -5,15 +5,12 @@ import cn.hutool.json.JSONObject;
import
me.zhengjie.domain.Log
;
import
me.zhengjie.repository.LogRepository
;
import
me.zhengjie.service.LogService
;
import
me.zhengjie.utils.SecurityUtils
;
import
me.zhengjie.utils.StringUtils
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
/**
...
...
@@ -31,7 +28,7 @@ public class LogServiceImpl implements LogService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
save
(
String
username
,
HttpServletRequest
request
,
ProceedingJoinPoint
joinPoint
,
Log
log
){
public
void
save
(
String
username
,
String
ip
,
ProceedingJoinPoint
joinPoint
,
Log
log
){
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
Method
method
=
signature
.
getMethod
();
...
...
@@ -57,7 +54,7 @@ public class LogServiceImpl implements LogService {
}
// 获取IP地址
log
.
setRequestIp
(
StringUtils
.
getIP
(
request
)
);
log
.
setRequestIp
(
ip
);
if
(
LOGINPATH
.
equals
(
signature
.
getName
())){
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录