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
669948f1
Commit
669948f1
authored
May 12, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复等待时间
parent
7e5db4a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
19 deletions
+44
-19
Log.java
...util-base/src/main/java/com/yanzuoguang/util/log/Log.java
+2
-4
LogDefault.java
...se/src/main/java/com/yanzuoguang/util/log/LogDefault.java
+11
-10
LogInfo.java
...-base/src/main/java/com/yanzuoguang/util/log/LogInfo.java
+31
-5
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/log/Log.java
View file @
669948f1
...
...
@@ -30,9 +30,7 @@ public class Log {
* @param args
*/
public
static
void
error
(
Class
<?>
cls
,
String
msg
,
Object
...
args
)
{
String
toMsg
=
getFormat
(
msg
,
args
);
Exception
ex
=
new
Exception
(
toMsg
);
error
(
cls
,
ex
);
error
(
cls
,
null
,
msg
,
args
);
}
/**
...
...
@@ -53,7 +51,7 @@ public class Log {
*/
public
static
void
error
(
Class
<?>
cls
,
Throwable
ex
,
String
msg
,
Object
...
args
)
{
String
toMsg
=
getFormat
(
msg
,
args
);
add
(
new
LogInfo
(
cls
,
new
Date
(),
ex
,
toMsg
));
add
(
new
LogInfo
(
cls
,
new
Date
(),
true
,
ex
,
toMsg
));
}
/**
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/log/LogDefault.java
View file @
669948f1
...
...
@@ -58,17 +58,18 @@ public class LogDefault implements RunnableLog {
sb
.
append
(
" */ "
);
sb
.
append
(
info
.
getMessage
());
Throwable
ex
=
info
.
getException
();
if
(
ex
!=
null
)
{
sb
.
append
(
ex
.
getClass
().
getName
());
sb
.
append
(
ex
.
getMessage
());
sb
.
append
(
System
.
getProperty
(
"line.separator"
));
System
.
err
.
print
(
sb
);
ex
.
printStackTrace
();
if
(
info
.
isError
())
{
Throwable
ex
=
info
.
getException
();
if
(
ex
!=
null
)
{
sb
.
append
(
ex
.
getClass
().
getName
());
sb
.
append
(
ex
.
getMessage
());
}
System
.
err
.
println
(
sb
);
if
(
ex
!=
null
)
{
ex
.
printStackTrace
();
}
}
else
{
sb
.
append
(
System
.
getProperty
(
"line.separator"
));
System
.
out
.
print
(
sb
);
System
.
out
.
println
(
sb
);
}
if
(!
StringHelper
.
isEmpty
(
pathFormat
))
{
...
...
yzg-util-base/src/main/java/com/yanzuoguang/util/log/LogInfo.java
View file @
669948f1
...
...
@@ -12,6 +12,10 @@ public class LogInfo {
* 触发类
*/
private
Class
<?>
cls
;
/**
* 是否出错
*/
private
boolean
error
;
/**
* 错误发生时间
*/
...
...
@@ -48,7 +52,7 @@ public class LogInfo {
* @param msg 日志消息
*/
public
LogInfo
(
String
msg
)
{
this
(
n
ew
Date
()
,
null
,
msg
);
this
(
n
ull
,
new
Date
(),
false
,
null
,
msg
);
}
/**
...
...
@@ -57,7 +61,7 @@ public class LogInfo {
* @param ex 异常信息
*/
public
LogInfo
(
Exception
ex
)
{
this
(
n
ew
Date
()
,
ex
,
""
);
this
(
n
ull
,
new
Date
(),
ex
!=
null
,
ex
,
""
);
}
/**
...
...
@@ -67,7 +71,7 @@ public class LogInfo {
* @param ex 异常信息
*/
public
LogInfo
(
Date
date
,
Exception
ex
)
{
this
(
date
,
ex
,
""
);
this
(
null
,
date
,
ex
!=
null
,
ex
,
""
);
}
/**
...
...
@@ -77,7 +81,7 @@ public class LogInfo {
* @param msg 消息
*/
public
LogInfo
(
Date
date
,
String
msg
)
{
this
(
dat
e
,
null
,
msg
);
this
(
null
,
date
,
fals
e
,
null
,
msg
);
}
/**
...
...
@@ -88,7 +92,7 @@ public class LogInfo {
* @param msg 消息
*/
public
LogInfo
(
Date
date
,
Throwable
ex
,
String
msg
)
{
this
(
null
,
date
,
ex
,
msg
);
this
(
null
,
date
,
ex
!=
null
,
ex
,
msg
);
}
/**
...
...
@@ -100,10 +104,24 @@ public class LogInfo {
* @param msg 消息
*/
public
LogInfo
(
Class
<?>
cls
,
Date
date
,
Throwable
ex
,
String
msg
)
{
this
(
cls
,
date
,
ex
!=
null
,
ex
,
msg
);
}
/**
* 构造函数
*
* @param cls 触发类
* @param date 时间
* @param error 是否出错
* @param ex 异常
* @param msg 消息
*/
public
LogInfo
(
Class
<?>
cls
,
Date
date
,
boolean
error
,
Throwable
ex
,
String
msg
)
{
this
.
cls
=
cls
;
this
.
setNow
(
date
);
this
.
setException
(
ex
);
this
.
setMessage
(
msg
);
this
.
error
=
error
;
}
public
Class
<?>
getCls
()
{
...
...
@@ -146,6 +164,14 @@ public class LogInfo {
this
.
message
=
message
;
}
public
boolean
isError
()
{
return
error
;
}
public
void
setError
(
boolean
error
)
{
this
.
error
=
error
;
}
public
Throwable
getException
()
{
return
exception
;
}
...
...
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