From 197c0cbd9d5904a22184a7be21a6cd01e495b348 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 21 May 2019 10:18:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=92=88=E5=AF=B9=E6=80=A7?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=BD=AC=E9=80=9A=E7=94=A8appender?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/DesignerLoggingProcessor.java | 16 --------- .../AbstractDesignerLoggingProcessor.java | 17 --------- .../loghandler/DesignerLogHandler.java | 5 --- .../mainframe/loghandler/DesignerLogger.java | 36 +++++++++++++++++++ .../mainframe/socketio/DesignerSocketIO.java | 11 ++---- 5 files changed, 38 insertions(+), 47 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/fun/DesignerLoggingProcessor.java delete mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerLoggingProcessor.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java diff --git a/designer-base/src/main/java/com/fr/design/fun/DesignerLoggingProcessor.java b/designer-base/src/main/java/com/fr/design/fun/DesignerLoggingProcessor.java deleted file mode 100644 index bc5540558..000000000 --- a/designer-base/src/main/java/com/fr/design/fun/DesignerLoggingProcessor.java +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerLoggingProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerLoggingProcessor.java deleted file mode 100644 index 177851d9b..000000000 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerLoggingProcessor.java +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 35abeb82c..cbdf3f956 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/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); - } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java new file mode 100644 index 000000000..2721d38cb --- /dev/null +++ b/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()); + } + } +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 6af58f8cd..10a1ee0bd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/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); }