Commit 669948f1 authored by yanzg's avatar yanzg

修复等待时间

parent 7e5db4a0
......@@ -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));
}
/**
......
......@@ -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)) {
......
......@@ -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(new Date(), null, msg);
this(null, new Date(), false, null, msg);
}
/**
......@@ -57,7 +61,7 @@ public class LogInfo {
* @param ex 异常信息
*/
public LogInfo(Exception ex) {
this(new Date(), ex, "");
this(null, 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(date, null, msg);
this(null, date, false, 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment