|
|
@ -17,20 +17,66 @@ public class DesignerLogger { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 记录LoggingEvent对象 |
|
|
|
* 记录LoggingEvent对象 |
|
|
|
|
|
|
|
* |
|
|
|
* @param event |
|
|
|
* @param event |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void log(LoggingEvent event) { |
|
|
|
public static void log(LoggingEvent event) { |
|
|
|
if (event == null) { |
|
|
|
if (event == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
int intLevel = event.getLevel().toInt(); |
|
|
|
LogParser.parse(event).log(event); |
|
|
|
ThrowableInformation information = event.getThrowableInformation(); |
|
|
|
} |
|
|
|
if (intLevel == INFO_INT) { |
|
|
|
|
|
|
|
|
|
|
|
public enum LogParser { |
|
|
|
|
|
|
|
DEFAULT(-1) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void log(LoggingEvent event) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
INFO(Level.INFO.toInt()) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void log(LoggingEvent event) { |
|
|
|
FineLoggerFactory.getLogger().info(event.getRenderedMessage()); |
|
|
|
FineLoggerFactory.getLogger().info(event.getRenderedMessage()); |
|
|
|
} else if (intLevel == ERROR_INT) { |
|
|
|
} |
|
|
|
FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable()); |
|
|
|
}, |
|
|
|
} else if (intLevel == WARN_INT) { |
|
|
|
WARN(Level.WARN.toInt()) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void log(LoggingEvent event) { |
|
|
|
|
|
|
|
ThrowableInformation information = event.getThrowableInformation(); |
|
|
|
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable()); |
|
|
|
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ERROR(Level.ERROR.toInt()) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void log(LoggingEvent event) { |
|
|
|
|
|
|
|
ThrowableInformation information = event.getThrowableInformation(); |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
private int level; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogParser(int level) { |
|
|
|
|
|
|
|
this.level = level; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getLevel() { |
|
|
|
|
|
|
|
return level; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static LogParser parse(LoggingEvent event) { |
|
|
|
|
|
|
|
int intLevel = event.getLevel().toInt(); |
|
|
|
|
|
|
|
for (LogParser logParser : values()) { |
|
|
|
|
|
|
|
if (logParser.getLevel() == intLevel) { |
|
|
|
|
|
|
|
return logParser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return DEFAULT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void log(LoggingEvent event) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |