Commit 669948f1 authored by yanzg's avatar yanzg

修复等待时间

parent 7e5db4a0
...@@ -30,9 +30,7 @@ public class Log { ...@@ -30,9 +30,7 @@ public class Log {
* @param args * @param args
*/ */
public static void error(Class<?> cls, String msg, Object... args) { public static void error(Class<?> cls, String msg, Object... args) {
String toMsg = getFormat(msg, args); error(cls, null, msg, args);
Exception ex = new Exception(toMsg);
error(cls, ex);
} }
/** /**
...@@ -53,7 +51,7 @@ public class Log { ...@@ -53,7 +51,7 @@ public class Log {
*/ */
public static void error(Class<?> cls, Throwable ex, String msg, Object... args) { public static void error(Class<?> cls, Throwable ex, String msg, Object... args) {
String toMsg = getFormat(msg, 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 { ...@@ -58,17 +58,18 @@ public class LogDefault implements RunnableLog {
sb.append(" */ "); sb.append(" */ ");
sb.append(info.getMessage()); sb.append(info.getMessage());
if (info.isError()) {
Throwable ex = info.getException(); Throwable ex = info.getException();
if (ex != null) { if (ex != null) {
sb.append(ex.getClass().getName()); sb.append(ex.getClass().getName());
sb.append(ex.getMessage()); sb.append(ex.getMessage());
sb.append(System.getProperty("line.separator")); }
System.err.print(sb); System.err.println(sb);
ex.printStackTrace(); if (ex != null) {
ex.printStackTrace();
}
} else { } else {
sb.append(System.getProperty("line.separator")); System.out.println(sb);
System.out.print(sb);
} }
if (!StringHelper.isEmpty(pathFormat)) { if (!StringHelper.isEmpty(pathFormat)) {
......
...@@ -12,6 +12,10 @@ public class LogInfo { ...@@ -12,6 +12,10 @@ public class LogInfo {
* 触发类 * 触发类
*/ */
private Class<?> cls; private Class<?> cls;
/**
* 是否出错
*/
private boolean error;
/** /**
* 错误发生时间 * 错误发生时间
*/ */
...@@ -48,7 +52,7 @@ public class LogInfo { ...@@ -48,7 +52,7 @@ public class LogInfo {
* @param msg 日志消息 * @param msg 日志消息
*/ */
public LogInfo(String msg) { public LogInfo(String msg) {
this(new Date(), null, msg); this(null, new Date(), false, null, msg);
} }
/** /**
...@@ -57,7 +61,7 @@ public class LogInfo { ...@@ -57,7 +61,7 @@ public class LogInfo {
* @param ex 异常信息 * @param ex 异常信息
*/ */
public LogInfo(Exception ex) { public LogInfo(Exception ex) {
this(new Date(), ex, ""); this(null, new Date(), ex != null, ex, "");
} }
/** /**
...@@ -67,7 +71,7 @@ public class LogInfo { ...@@ -67,7 +71,7 @@ public class LogInfo {
* @param ex 异常信息 * @param ex 异常信息
*/ */
public LogInfo(Date date, Exception ex) { public LogInfo(Date date, Exception ex) {
this(date, ex, ""); this(null, date, ex != null, ex, "");
} }
/** /**
...@@ -77,7 +81,7 @@ public class LogInfo { ...@@ -77,7 +81,7 @@ public class LogInfo {
* @param msg 消息 * @param msg 消息
*/ */
public LogInfo(Date date, String msg) { public LogInfo(Date date, String msg) {
this(date, null, msg); this(null, date, false, null, msg);
} }
/** /**
...@@ -88,7 +92,7 @@ public class LogInfo { ...@@ -88,7 +92,7 @@ public class LogInfo {
* @param msg 消息 * @param msg 消息
*/ */
public LogInfo(Date date, Throwable ex, String 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 { ...@@ -100,10 +104,24 @@ public class LogInfo {
* @param msg 消息 * @param msg 消息
*/ */
public LogInfo(Class<?> cls, Date date, Throwable ex, String 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.cls = cls;
this.setNow(date); this.setNow(date);
this.setException(ex); this.setException(ex);
this.setMessage(msg); this.setMessage(msg);
this.error = error;
} }
public Class<?> getCls() { public Class<?> getCls() {
...@@ -146,6 +164,14 @@ public class LogInfo { ...@@ -146,6 +164,14 @@ public class LogInfo {
this.message = message; this.message = message;
} }
public boolean isError() {
return error;
}
public void setError(boolean error) {
this.error = error;
}
public Throwable getException() { public Throwable getException() {
return exception; 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