Browse Source

去掉针对性接口,转通用appender实现

bugfix/10.0
zack 6 years ago
parent
commit
197c0cbd9d
  1. 16
      designer-base/src/main/java/com/fr/design/fun/DesignerLoggingProcessor.java
  2. 17
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerLoggingProcessor.java
  3. 5
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  4. 36
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java
  5. 11
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

16
designer-base/src/main/java/com/fr/design/fun/DesignerLoggingProcessor.java

@ -1,16 +0,0 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Immutable;
import com.fr.third.apache.log4j.spi.LoggingEvent;
public interface DesignerLoggingProcessor extends Immutable {
int CURRENT_LEVEL = 1;
String XML_TAG = "DesignerLoggingProcessor";
/**
* 输出日志对象
* @param loggingEvent 日志对象
*/
void printLoggingEvent(LoggingEvent loggingEvent);
}

17
designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerLoggingProcessor.java

@ -1,17 +0,0 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.DesignerLoggingProcessor;
import com.fr.stable.fun.mark.API;
@API(level = DesignerLoggingProcessor.CURRENT_LEVEL)
public abstract class AbstractDesignerLoggingProcessor implements DesignerLoggingProcessor {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

5
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -368,9 +368,4 @@ public class DesignerLogHandler {
};
}
public void printLoggingEvent(LoggingEvent event) {
logHandlerArea.printStackTrace(event);
}
}

36
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java

@ -0,0 +1,36 @@
package com.fr.design.mainframe.loghandler;
import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
/**
* 设计器日志记录
*/
public class DesignerLogger {
public static final int INFO_INT = Level.INFO.toInt();
public static final int ERROR_INT = Level.ERROR.toInt();
public static final int WARN_INT = Level.WARN.toInt();
/**
* 记录LoggingEvent对象
* @param event
*/
public static void log(LoggingEvent event) {
if (event == null) {
return;
}
int intLevel = event.getLevel().toInt();
ThrowableInformation information = event.getThrowableInformation();
if (intLevel == INFO_INT) {
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) {
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable());
}
}
}

11
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -3,11 +3,9 @@ package com.fr.design.mainframe.socketio;
import com.fr.config.RemoteConfigEvent;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.DesignerLoggingProcessor;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.design.mainframe.loghandler.DesignerLogger;
import com.fr.event.EventDispatcher;
import com.fr.log.FineLoggerFactory;
import com.fr.report.RemoteDesignConstants;
@ -48,12 +46,7 @@ public class DesignerSocketIO {
if (ArrayUtils.isNotEmpty(objects)) {
try {
LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]);
DesignerLoggingProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerLoggingProcessor.XML_TAG);
if (processor != null) {
processor.printLoggingEvent(event);
}else {
DesignerLogHandler.getInstance().printLoggingEvent(event);
}
DesignerLogger.log(event);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}

Loading…
Cancel
Save