From 655dfbc51dd734f296516dd2f4cef874b4f7e84f Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 17 Oct 2017 20:47:23 +0800 Subject: [PATCH] =?UTF-8?q?PFC-1053=20log=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../errorinfo/ErrorInfoLogAppender.java | 10 +++++----- .../errorinfo/ErrorInfoUploader.java | 15 ++++++++++++-- .../src/com/fr/design/DesignerEnvManager.java | 2 +- .../mainframe/EastRegionContainerPane.java | 16 +++++++++------ .../loghandler/DesignerLogAppender.java | 12 ++++++----- .../loghandler/DesignerLogHandler.java | 20 ++++++++++++------- 6 files changed, 49 insertions(+), 26 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index 30356efe8f..6923e4fae1 100644 --- a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java @@ -13,11 +13,11 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; +import com.fr.third.apache.log4j.AppenderSkeleton; +import com.fr.third.apache.log4j.Level; +import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.web.core.SessionDealWith; import com.fr.web.core.SessionIDInfor; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Level; -import org.apache.log4j.spi.LoggingEvent; import java.io.InputStream; @@ -36,7 +36,7 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { private String activekey; public ErrorInfoLogAppender() { - this.layout = new org.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); + this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); this.username = ConfigManager.getProviderInstance().getBbsUsername(); @@ -63,7 +63,7 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { public void subAppend(LoggingEvent event) { Level level = event.getLevel(); // 只分析上传记录error以上的. - if (level.isGreaterOrEqual(FRLogLevel.ERROR)) { + if (level.isGreaterOrEqual(Level.ERROR)) { String msg = this.layout.format(event); // 这个id并不是一定会有的, 有就记录下, 说明是预览模板出的错. String templateid = readTemplateID(); diff --git a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index 2651fdd1cb..43847170ab 100644 --- a/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -10,6 +10,7 @@ import com.fr.general.http.HttpClient; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.license.function.VT4FR; +import com.fr.log.LogHandler; import com.fr.stable.CodeUtils; import com.fr.stable.EnvChangedListener; import com.fr.stable.ProductConstants; @@ -40,7 +41,12 @@ public class ErrorInfoUploader { GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override public void envChanged() { - FRLogger.getLogger().addLogAppender(new ErrorInfoLogAppender()); + FRLogger.getLogger().addLogAppender(new LogHandler() { + @Override + public ErrorInfoLogAppender getHandler() { + return new ErrorInfoLogAppender(); + } + }); } }); @@ -49,7 +55,12 @@ public class ErrorInfoUploader { } private ErrorInfoUploader() { - FRLogger.getLogger().addLogAppender(new ErrorInfoLogAppender()); + FRLogger.getLogger().addLogAppender(new LogHandler() { + @Override + public ErrorInfoLogAppender getHandler() { + return new ErrorInfoLogAppender(); + } + }); } public static ErrorInfoUploader getInstance() { diff --git a/designer_base/src/com/fr/design/DesignerEnvManager.java b/designer_base/src/com/fr/design/DesignerEnvManager.java index 0e76122141..f43d05bacd 100644 --- a/designer_base/src/com/fr/design/DesignerEnvManager.java +++ b/designer_base/src/com/fr/design/DesignerEnvManager.java @@ -33,7 +33,6 @@ import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; -import org.apache.log4j.Level; import javax.swing.*; import javax.swing.SwingWorker.StateValue; @@ -54,6 +53,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.logging.FileHandler; import java.util.logging.Handler; +import java.util.logging.Level; /** * The manager of Designer GUI. diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index f6393add67..04f13ff7c2 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -10,19 +10,23 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; -import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.Inter; import com.fr.stable.StringUtils; -import com.fr.third.fr.pdf.kernel.utils.CompareTool; -import com.sap.conn.jco.JCo; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.util.List; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; public class EastRegionContainerPane extends UIEastResizableContainer { private static EastRegionContainerPane THIS; diff --git a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogAppender.java b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogAppender.java index 0531748af2..cf9e231149 100644 --- a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogAppender.java +++ b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogAppender.java @@ -1,8 +1,10 @@ package com.fr.design.mainframe.loghandler; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Level; -import org.apache.log4j.spi.LoggingEvent; + +import com.fr.general.FRLogLevel; +import com.fr.third.apache.log4j.AppenderSkeleton; +import com.fr.third.apache.log4j.Level; +import com.fr.third.apache.log4j.spi.LoggingEvent; import java.util.Date; @@ -12,7 +14,7 @@ import java.util.Date; public class DesignerLogAppender extends AppenderSkeleton { public DesignerLogAppender() { - this.layout = new org.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); + this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); } protected void append(LoggingEvent event) { @@ -35,7 +37,7 @@ public class DesignerLogAppender extends AppenderSkeleton { synchronized (DesignerLogHandler.getInstance()) { Level level = event.getLevel(); String msg = this.layout.format(event); - DesignerLogHandler.getInstance().printRemoteLog(msg, level, new Date()); + DesignerLogHandler.getInstance().printRemoteLog(msg, FRLogLevel.convertLog4jToJava(level), new Date()); } } } diff --git a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 466c9b56d9..740bd4ffe1 100644 --- a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -7,9 +7,9 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.*; +import com.fr.log.LogHandler; import com.fr.stable.EnvChangedListener; import com.fr.stable.xml.LogRecordTimeProvider; -import org.apache.log4j.Level; import javax.swing.*; import javax.swing.text.*; @@ -17,14 +17,15 @@ import java.awt.*; import java.awt.event.*; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.logging.Level; import java.util.logging.LogRecord; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; public class DesignerLogHandler { - protected static final int INFO_INT = FRLogLevel.INFO.toInt(); - protected static final int ERRO_INT = FRLogLevel.ERROR.toInt(); - protected static final int SERVER_INT = FRLogLevel.SEVERE.toInt(); + protected static final int INFO_INT = FRLogLevel.INFO.intValue(); + protected static final int ERRO_INT = FRLogLevel.ERROR.intValue(); + protected static final int SERVER_INT = FRLogLevel.SEVERE.intValue(); private static final int GAP_X = -150; private static final int INFO_GAP_Y = -60; private static final int ERRO_GAP_Y = -40; @@ -35,7 +36,12 @@ public class DesignerLogHandler { @Override public void envChanged() { // envchange后需要重新读取webinf里的log4j配置, 重新添加appender - FRLogger.getLogger().addLogAppender(new DesignerLogAppender()); + FRLogger.getLogger().addLogAppender(new LogHandler() { + @Override + public DesignerLogAppender getHandler() { + return new DesignerLogAppender(); + } + }); } }); } @@ -99,7 +105,7 @@ public class DesignerLogHandler { @Override public void actionPerformed(ActionEvent e) { JPopupMenu showsetPopup = new JPopupMenu(); - int logLevelvalue = DesignerEnvManager.getEnvManager().getLogLevel().toInt(); + int logLevelvalue = DesignerEnvManager.getEnvManager().getLogLevel().intValue(); if (logLevelvalue <= INFO_INT) { showsetPopup.add(showInfo); showsetPopup.add(showError); @@ -211,7 +217,7 @@ public class DesignerLogHandler { } public void printStackTrace(String message, Level level, Date date) { - int logLevelvalue = level.toInt(); + int logLevelvalue = level.intValue(); if (logLevelvalue == INFO_INT && showInfo.isSelected()) { printMessage(message, logLevelvalue, date); } else if (logLevelvalue == ERRO_INT && showError.isSelected()) {