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
e3517dc3
Commit
e3517dc3
authored
Mar 23, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
不记录系统日志
parent
36056d40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
27 deletions
+42
-27
LogLocal.java
...oud/src/main/java/com/yanzuoguang/cloud/aop/LogLocal.java
+15
-24
Timeout.java
...loud/src/main/java/com/yanzuoguang/cloud/aop/Timeout.java
+27
-3
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/LogLocal.java
View file @
e3517dc3
...
...
@@ -22,16 +22,24 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
* 缓存队列
*/
protected
volatile
Map
<
String
,
Timeout
<
LogVo
>>
cache
=
new
Hashtable
<>();
/**
* 日志基础
*/
@Autowired
private
LogBase
logBase
;
@Value
(
"${spring.application.name}"
)
protected
String
applicationName
;
/**
* 1个请求最长时间
* 1个请求最长时间(毫秒)
*/
@Value
(
"${yzg.log.time.max:300000}"
)
private
int
logTimeMax
;
/**
* 1个请求间隔记录时间(毫秒)
*/
@Value
(
"${yzg.
timeou
t:300000}"
)
private
int
timeou
t
;
@Value
(
"${yzg.
log.time.spli
t:300000}"
)
private
int
logTimeSpli
t
;
@Value
(
"${yzg.log.notFilter:^.*login.*$}"
)
private
String
notFilter
;
...
...
@@ -45,12 +53,6 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
public
static
final
String
MAX_TIME
=
"MAX_TIME"
;
public
static
final
String
MAX_TIME_NAME
=
"执行超时"
;
/**
* 日志基础
*/
@Autowired
private
LogBase
logBase
;
/**
* Invoked by a BeanFactory after it has set all bean properties supplied
* (and satisfied BeanFactoryAware and ApplicationContextAware).
...
...
@@ -99,19 +101,8 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
* @return
*/
public
void
result
(
LogVo
log
,
String
status
,
String
result
)
{
this
.
result
(
log
,
StringHelper
.
EMPTY
,
status
,
result
);
}
/**
* 写入状态
*
* @param status
* @param result
* @return
*/
public
void
result
(
LogVo
log
,
String
name
,
String
status
,
String
result
)
{
// 日志请求不记录,防止死循环递归
boolean
isLog
=
isLog
(
name
,
log
.
getActionSubKey
());
boolean
isLog
=
isLog
(
log
.
getActionKey
()
,
log
.
getActionSubKey
());
if
(
isLog
)
{
this
.
remove
(
log
);
}
else
{
...
...
@@ -200,7 +191,7 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
keys
.
addAll
(
cache
.
keySet
());
for
(
String
key
:
keys
)
{
Timeout
<
LogVo
>
timeout
=
cache
.
get
(
key
);
if
(
timeout
==
null
||
!
timeout
.
isMaxTime
(
this
.
timeou
t
))
{
if
(
timeout
==
null
||
!
timeout
.
isMaxTime
(
this
.
logTimeMax
,
this
.
logTimeSpli
t
))
{
continue
;
}
writeTimeout
(
timeout
);
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/Timeout.java
View file @
e3517dc3
...
...
@@ -13,6 +13,11 @@ public class Timeout<T extends Object> {
*/
private
long
start
;
/**
* 上次通知时间
*/
private
long
prev
;
/**
* 结束时间
*/
...
...
@@ -25,6 +30,7 @@ public class Timeout<T extends Object> {
*/
public
Timeout
(
T
data
)
{
this
.
start
=
System
.
currentTimeMillis
();
this
.
prev
=
start
;
this
.
data
=
data
;
}
...
...
@@ -37,6 +43,15 @@ public class Timeout<T extends Object> {
return
start
;
}
/**
* 上次判断时间
*
* @return
*/
public
long
getPrev
()
{
return
prev
;
}
/**
* 数据
*
...
...
@@ -52,8 +67,17 @@ public class Timeout<T extends Object> {
* @param maxTime 最大时间
* @return
*/
public
boolean
isMaxTime
(
long
maxTime
)
{
long
time
=
System
.
currentTimeMillis
()
-
start
;
return
maxTime
<
time
;
public
boolean
isMaxTime
(
long
maxTime
,
long
prevMaxTime
)
{
long
now
=
System
.
currentTimeMillis
();
long
time
=
now
-
start
;
long
prevTime
=
now
-
prev
;
boolean
ret
=
maxTime
<
time
;
if
(
ret
)
{
if
(
prev
!=
start
&&
prevMaxTime
>
prevTime
)
{
return
false
;
}
prev
=
now
;
}
return
ret
;
}
}
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