Browse Source

1.原本输出的日志里,WARN标签对应严重,ERROR标签对应警告

2.修改后,ERROR标签对应严重,WARN标签对应警告,并相应的修改其配色和计数
3.添加一些常量,使代码更符合帆软规范
feature/big-screen
Yvan 4 years ago
parent
commit
c3ce3949aa
  1. 25
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

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

@ -8,6 +8,7 @@ import com.fr.design.ui.util.UIUtil;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation; import com.fr.third.apache.log4j.spi.ThrowableInformation;
@ -53,12 +54,14 @@ public class DesignerLogHandler {
private static final int SERVER_GAP_Y = -20; private static final int SERVER_GAP_Y = -20;
private static final String ERROR_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":"; private static final String ERROR_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":";
private static final String WARN_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":"; private static final String WARN_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":";
private static final String NORMAL_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":"; private static final String NORMAL_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":";
private static final String ACTION_MAP_KEY = "clear";
public static DesignerLogHandler getInstance() { public static DesignerLogHandler getInstance() {
return HOLDER.singleton; return HOLDER.singleton;
@ -223,14 +226,14 @@ public class DesignerLogHandler {
InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), "clear"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), ACTION_MAP_KEY);
ActionMap actionMap = resultPane.getActionMap(); ActionMap actionMap = resultPane.getActionMap();
actionMap.put("clear", new AbstractAction() { actionMap.put(ACTION_MAP_KEY, new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
resultPane.setText(""); resultPane.setText(StringUtils.EMPTY);
caption.clearMessage(); caption.clearMessage();
} }
}); });
@ -293,10 +296,10 @@ public class DesignerLogHandler {
SimpleAttributeSet attrSet = new SimpleAttributeSet(); SimpleAttributeSet attrSet = new SimpleAttributeSet();
if (style == DesignerLogger.ERROR_INT) { if (style == DesignerLogger.ERROR_INT) {
StyleConstants.setForeground(attrSet, new Color(247, 148, 29)); StyleConstants.setForeground(attrSet, Color.RED);
StyleConstants.setBold(attrSet, true); StyleConstants.setBold(attrSet, true);
} else if (style == DesignerLogger.WARN_INT) { } else if (style == DesignerLogger.WARN_INT) {
StyleConstants.setForeground(attrSet, Color.red); StyleConstants.setForeground(attrSet, new Color(247, 148, 29));
StyleConstants.setBold(attrSet, true); StyleConstants.setBold(attrSet, true);
} else if (style == DesignerLogger.INFO_INT) { } else if (style == DesignerLogger.INFO_INT) {
StyleConstants.setForeground(attrSet, Color.black); StyleConstants.setForeground(attrSet, Color.black);
@ -330,9 +333,9 @@ public class DesignerLogHandler {
LogMessageBar.getInstance().setMessage(message); LogMessageBar.getInstance().setMessage(message);
if (level == DesignerLogger.INFO_INT && showInfo.isSelected()) { if (level == DesignerLogger.INFO_INT && showInfo.isSelected()) {
caption.infoAdd(); caption.infoAdd();
} else if (level == DesignerLogger.ERROR_INT && showError.isSelected()) { } else if (level == DesignerLogger.WARN_INT && showError.isSelected()) {
caption.errorAdd(); caption.errorAdd();
} else if (level == DesignerLogger.WARN_INT && showServer.isSelected()) { } else if (level == DesignerLogger.ERROR_INT && showServer.isSelected()) {
caption.serverAdd(); caption.serverAdd();
} }
} }
@ -343,7 +346,7 @@ public class DesignerLogHandler {
this.copy.setEnabled(true); this.copy.setEnabled(true);
this.clear.setEnabled(true); this.clear.setEnabled(true);
if (ComparatorUtils.equals(this.jTextArea.getText(), "")) { if (ComparatorUtils.equals(this.jTextArea.getText(), StringUtils.EMPTY)) {
this.selectAll.setEnabled(false); this.selectAll.setEnabled(false);
this.clear.setEnabled(false); this.clear.setEnabled(false);
} }
@ -367,7 +370,7 @@ public class DesignerLogHandler {
} else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.copy.getText())) { } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.copy.getText())) {
LogHandlerArea.this.jTextArea.copy(); LogHandlerArea.this.jTextArea.copy();
} else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.clear.getText())) { } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.clear.getText())) {
LogHandlerArea.this.jTextArea.setText(""); LogHandlerArea.this.jTextArea.setText(StringUtils.EMPTY);
caption.clearMessage(); caption.clearMessage();
} }
} }

Loading…
Cancel
Save