logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r1178301 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ resources/org/apache/log4j/chainsaw/help/
Date Mon, 03 Oct 2011 05:38:28 GMT
Author: sdeboy
Date: Mon Oct  3 05:38:28 2011
New Revision: 1178301

URL: http://svn.apache.org/viewvc?rev=1178301&view=rev
Log:
Added persistent "always display" expression support (button below the logger tree).  The
'always display' expression overrides hidden loggers and the hidden expression but not the
refine focus filtering mechanism.  Often used with expressions like 'exception exists || level
> warn' to ensure errors and exceptions are not filtered out due to the hidden expression
or hidden logger mechanism.

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
    logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java?rev=1178301&r1=1178300&r2=1178301&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java Mon Oct 
3 05:38:28 2011
@@ -2335,6 +2335,7 @@ public class LogPanel extends DockablePa
     searchModel.setCyclic(preferenceModel.isCyclic());
     logTreePanel.ignore(preferenceModel.getHiddenLoggers());
     logTreePanel.setHiddenExpression(preferenceModel.getHiddenExpression());
+    logTreePanel.setAlwaysDisplayExpression(preferenceModel.getAlwaysDisplayExpression());
     if (preferenceModel.getClearTableExpression() != null) {
         try {
             clearTableExpressionRule = ExpressionRule.getRule(preferenceModel.getClearTableExpression());
@@ -2366,6 +2367,7 @@ public class LogPanel extends DockablePa
 
     preferenceModel.setHiddenLoggers(new HashSet(logTreePanel.getHiddenSet()));
     preferenceModel.setHiddenExpression(logTreePanel.getHiddenExpression());
+    preferenceModel.setAlwaysDisplayExpression(logTreePanel.getAlwaysDisplayExpression());
     List visibleOrder = new ArrayList();
     Enumeration cols = table.getColumnModel().getColumns();
     while (cols.hasMoreElements()) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java?rev=1178301&r1=1178300&r2=1178301&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
Mon Oct  3 05:38:28 2011
@@ -84,6 +84,7 @@ public class LogPanelPreferenceModel imp
   private boolean wrapMsg = true;
   private boolean highlightSearchMatchText;
   private String hiddenExpression;
+  private String alwaysDisplayExpression;
   private String clearTableExpression;
   //default to cyclic mode off
   private boolean cyclic = false;
@@ -254,6 +255,7 @@ public class LogPanelPreferenceModel imp
     setVisibleColumns(model.getVisibleColumns());
     setHiddenLoggers(model.getHiddenLoggers());
     setHiddenExpression(model.getHiddenExpression());
+    setAlwaysDisplayExpression(model.getAlwaysDisplayExpression());
     setShowMillisDeltaAsGap(model.isShowMillisDeltaAsGap());
     setClearTableExpression(model.getClearTableExpression());
   }
@@ -506,6 +508,16 @@ public class LogPanelPreferenceModel imp
     return hiddenExpression;
   }
 
+  public void setAlwaysDisplayExpression(String alwaysDisplayExpression) {
+    Object oldValue = this.hiddenExpression;
+    this.alwaysDisplayExpression = alwaysDisplayExpression;
+    propertySupport.firePropertyChange("alwaysDisplayExpression", oldValue, this.alwaysDisplayExpression);
+  }
+
+  public String getAlwaysDisplayExpression() {
+    return alwaysDisplayExpression;
+  }
+
   public void setClearTableExpression(String clearTableExpression) {
     Object oldValue = this.clearTableExpression;
     this.clearTableExpression = clearTableExpression;

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java?rev=1178301&r1=1178300&r2=1178301&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
Mon Oct  3 05:38:28 2011
@@ -137,11 +137,14 @@ final class LoggerNameTreePanel extends 
 
   private final JList ignoreList = new JList();
   private final JEditorPane ignoreExpressionEntryField = new JEditorPane();
+  private final JEditorPane alwaysDisplayExpressionEntryField = new JEditorPane();
   private final JScrollPane ignoreListScroll = new JScrollPane(ignoreList);
   private final JDialog ignoreDialog = new JDialog();
   private final JDialog ignoreExpressionDialog = new JDialog();
+  private final JDialog alwaysDisplayExpressionDialog = new JDialog();
   private final JLabel ignoreSummary = new JLabel("0 hidden loggers");
   private final JLabel ignoreExpressionSummary = new JLabel("Ignore expression");
+  private final JLabel alwaysDisplayExpressionSummary = new JLabel("Always displayed expression");
   private final SmallToggleButton ignoreLoggerButton = new SmallToggleButton();
   private final EventListenerList listenerList = new EventListenerList();
   private final JTree logTree;
@@ -159,6 +162,7 @@ final class LoggerNameTreePanel extends 
   private final LogPanel logPanel;
   private final RuleColorizer colorizer;
   private Rule ignoreExpressionRule;
+  private Rule alwaysDisplayExpressionRule;
   private boolean expandRootLatch = false;
   private String currentlySelectedLoggerName;
 
@@ -179,12 +183,13 @@ final class LoggerNameTreePanel extends 
 
     setLayout(new BorderLayout());
     ignoreExpressionEntryField.setPreferredSize(new Dimension(300, 150));
-
+    alwaysDisplayExpressionEntryField.setPreferredSize(new Dimension(300, 150));
+    alwaysDisplayExpressionSummary.setMinimumSize(new Dimension(10, alwaysDisplayExpressionSummary.getHeight()));
     ignoreExpressionSummary.setMinimumSize(new Dimension(10, ignoreExpressionSummary.getHeight()));
     ignoreSummary.setMinimumSize(new Dimension(10, ignoreSummary.getHeight()));
 
     JTextComponentFormatter.applySystemFontAndSize(ignoreExpressionEntryField);
-
+    JTextComponentFormatter.applySystemFontAndSize(alwaysDisplayExpressionEntryField);
 
     visibilityRuleDelegate = new VisibilityRuleDelegate();
     colorRuleDelegate = 
@@ -194,7 +199,8 @@ final class LoggerNameTreePanel extends 
           {
             boolean hiddenLogger = e.getLoggerName() != null && isHiddenLogger(e.getLoggerName());
             boolean hiddenExpression = (ignoreExpressionRule != null && ignoreExpressionRule.evaluate(e,
null));
-            boolean hidden = hiddenLogger || hiddenExpression;
+            boolean alwaysDisplayExpression = (alwaysDisplayExpressionRule != null &&
alwaysDisplayExpressionRule.evaluate(e, null));
+            boolean hidden = (!alwaysDisplayExpression) && (hiddenLogger || hiddenExpression);
             String currentlySelectedLoggerName = getCurrentlySelectedLoggerName();
 
             if (!isFocusOnSelected() && !hidden && currentlySelectedLoggerName
!= null && !"".equals(currentlySelectedLoggerName))
@@ -298,6 +304,9 @@ final class LoggerNameTreePanel extends 
     ignoreExpressionDialog.setTitle("Hidden/Ignored Expression");
     ignoreExpressionDialog.setModal(true);
 
+    alwaysDisplayExpressionDialog.setTitle("Always displayed Expression");
+    alwaysDisplayExpressionDialog.setModal(true);
+
     JPanel ignorePanel = new JPanel();
     ignorePanel.setLayout(new BoxLayout(ignorePanel, BoxLayout.Y_AXIS));
     JPanel ignoreSummaryPanel = new JPanel();
@@ -315,6 +324,14 @@ final class LoggerNameTreePanel extends 
           LogPanel.centerAndSetVisible(ignoreExpressionDialog);
       }
     };
+
+
+    Action showAlwaysDisplayExpressionDialogAction = new AbstractAction("...") {
+      public void actionPerformed(ActionEvent e) {
+          LogPanel.centerAndSetVisible(alwaysDisplayExpressionDialog);
+      }
+    };
+
     showIgnoreDialogAction.putValue(Action.SHORT_DESCRIPTION, "Click to view and manage your
hidden/ignored loggers");
     JButton btnShowIgnoreDialog = new SmallButton(showIgnoreDialogAction);
     
@@ -329,6 +346,16 @@ final class LoggerNameTreePanel extends 
     ignoreExpressionPanel.add(btnShowIgnoreExpressionDialog);
 
     ignorePanel.add(ignoreExpressionPanel);
+
+    JPanel alwaysDisplayExpressionPanel = new JPanel();
+    alwaysDisplayExpressionPanel.setLayout(new BoxLayout(alwaysDisplayExpressionPanel, BoxLayout.X_AXIS));
+    alwaysDisplayExpressionPanel.add(alwaysDisplayExpressionSummary);
+    showAlwaysDisplayExpressionDialogAction.putValue(Action.SHORT_DESCRIPTION, "Click to
view and manage your always-displayed expression");
+    JButton btnShowAlwaysDisplayExpressionDialog = new SmallButton(showAlwaysDisplayExpressionDialogAction);
+    alwaysDisplayExpressionPanel.add(btnShowAlwaysDisplayExpressionDialog);
+
+    ignorePanel.add(alwaysDisplayExpressionPanel);
+
     add(ignorePanel, BorderLayout.SOUTH);
 
     ignoreList.setModel(new DefaultListModel());
@@ -376,9 +403,29 @@ final class LoggerNameTreePanel extends 
                 ignoreExpressionDialog.setVisible(false);
               }
           }});
-    JPanel closePanel = new JPanel();
-    closePanel.add(ignoreExpressionCloseButton);
-    ignoreExpressionDialogPanel.add(closePanel, BorderLayout.SOUTH);
+
+
+    JPanel alwaysDisplayExpressionDialogPanel = new JPanel(new BorderLayout());
+    alwaysDisplayExpressionEntryField.addKeyListener(new ExpressionRuleContext(filterModel,
alwaysDisplayExpressionEntryField));
+
+    alwaysDisplayExpressionDialogPanel.add(new JScrollPane(alwaysDisplayExpressionEntryField),
BorderLayout.CENTER);
+    JButton alwaysDisplayExpressionCloseButton = new JButton(new AbstractAction(" Close ")
{
+          public void actionPerformed(ActionEvent e)
+          {
+              String alwaysDisplayText = alwaysDisplayExpressionEntryField.getText();
+
+              if (updateAlwaysDisplayExpression(alwaysDisplayText)) {
+                alwaysDisplayExpressionDialog.setVisible(false);
+              }
+          }});
+
+    JPanel closeAlwaysDisplayExpressionPanel = new JPanel();
+    closeAlwaysDisplayExpressionPanel.add(alwaysDisplayExpressionCloseButton);
+    alwaysDisplayExpressionDialogPanel.add(closeAlwaysDisplayExpressionPanel, BorderLayout.SOUTH);
+
+    JPanel closeIgnoreExpressionPanel = new JPanel();
+    closeIgnoreExpressionPanel.add(ignoreExpressionCloseButton);
+    ignoreExpressionDialogPanel.add(closeIgnoreExpressionPanel, BorderLayout.SOUTH);
 
     Box ignoreListButtonPanel = Box.createHorizontalBox();
     
@@ -415,6 +462,9 @@ final class LoggerNameTreePanel extends 
 
     ignoreExpressionDialog.getContentPane().add(ignoreExpressionDialogPanel);
     ignoreExpressionDialog.pack();
+
+    alwaysDisplayExpressionDialog.getContentPane().add(alwaysDisplayExpressionDialogPanel);
+    alwaysDisplayExpressionDialog.pack();
   }
 
     private boolean updateIgnoreExpression(String ignoreText)
@@ -427,7 +477,7 @@ final class LoggerNameTreePanel extends 
             }
             visibilityRuleDelegate.firePropertyChange("hiddenSet", null, null);
 
-            updateAllIgnoreStuff();
+            updateDisplay();
             ignoreExpressionEntryField.setBackground(UIManager.getColor("TextField.background"));
             return true;
         } catch (IllegalArgumentException iae) {
@@ -437,6 +487,26 @@ final class LoggerNameTreePanel extends 
         }
     }
 
+    private boolean updateAlwaysDisplayExpression(String alwaysDisplayText)
+    {
+        try {
+            if (alwaysDisplayText != null && !alwaysDisplayText.trim().equals(""))
{
+                alwaysDisplayExpressionRule = ExpressionRule.getRule(alwaysDisplayText);
+            } else {
+                alwaysDisplayExpressionRule = null;
+            }
+            visibilityRuleDelegate.firePropertyChange("alwaysDisplayedSet", null, null);
+
+            updateDisplay();
+            alwaysDisplayExpressionEntryField.setBackground(UIManager.getColor("TextField.background"));
+            return true;
+        } catch (IllegalArgumentException iae) {
+            alwaysDisplayExpressionEntryField.setToolTipText(iae.getMessage());
+            alwaysDisplayExpressionEntryField.setBackground(ChainsawConstants.INVALID_EXPRESSION_BACKGROUND);
+            return false;
+        }
+    }
+
     //~ Methods =================================================================
 
   /**
@@ -1426,7 +1496,7 @@ final class LoggerNameTreePanel extends 
         public void stateChanged(ChangeEvent evt)
         {
           visibilityRuleDelegate.firePropertyChange("rule", null, null);
-          updateAllIgnoreStuff();
+          updateDisplay();
         }
       });
 
@@ -1435,16 +1505,17 @@ final class LoggerNameTreePanel extends 
         public void propertyChange(PropertyChangeEvent event)
         {
           if (event.getPropertyName().equals("hiddenSet")) {
-            updateAllIgnoreStuff();
+            updateDisplay();
           }
         }
       });
   }
 
-  private void updateAllIgnoreStuff() {
+  private void updateDisplay() {
       updateHiddenSetModels();
       updateIgnoreSummary();
       updateIgnoreExpressionSummary();
+      updateAlwaysDisplayExpressionSummary();
   }
   
   private void updateHiddenSetModels() {
@@ -1470,6 +1541,10 @@ final class LoggerNameTreePanel extends 
     ignoreExpressionSummary.setText(ignoreExpressionRule != null?"Ignore (set)":"Ignore (unset)");
   }
   
+  private void updateAlwaysDisplayExpressionSummary() {
+    alwaysDisplayExpressionSummary.setText(alwaysDisplayExpressionRule != null?"Always displayed
(set)":"Always displayed (unset)");
+  }
+
   private void toggleFocusOnState()
   {
     setFocusOnSelected(!isFocusOnSelected());
@@ -1493,6 +1568,19 @@ final class LoggerNameTreePanel extends 
         updateIgnoreExpression(hiddenExpression);
     }
 
+    public String getAlwaysDisplayExpression() {
+        String text = alwaysDisplayExpressionEntryField.getText();
+        if (text == null || text.trim().equals("")) {
+            return null;
+        }
+        return text.trim();
+    }
+
+    public void setAlwaysDisplayExpression(String alwaysDisplayExpression) {
+        alwaysDisplayExpressionEntryField.setText(alwaysDisplayExpression);
+        updateAlwaysDisplayExpression(alwaysDisplayExpression);
+    }
+
     public void loggerNameAdded(String loggerName)
     {
         //no-op
@@ -1810,7 +1898,8 @@ final class LoggerNameTreePanel extends 
           String currentlySelectedLoggerName = getCurrentlySelectedLoggerName();
           boolean hiddenLogger = e.getLoggerName() != null && isHiddenLogger(e.getLoggerName());
           boolean hiddenExpression = (ignoreExpressionRule != null && ignoreExpressionRule.evaluate(e,
null));
-          boolean hidden = hiddenLogger || hiddenExpression;
+          boolean alwaysDisplayExpression = (alwaysDisplayExpressionRule != null &&
alwaysDisplayExpressionRule.evaluate(e, null));
+          boolean hidden = (!alwaysDisplayExpression) && (hiddenLogger || hiddenExpression);
           if (currentlySelectedLoggerName == null) {
           	//if there is no selected logger, pass if not hidden
           	return !hidden;

Modified: logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html?rev=1178301&r1=1178300&r2=1178301&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html
(original)
+++ logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html
Mon Oct  3 05:38:28 2011
@@ -10,6 +10,10 @@
 <b>NOTE:</b> The mechanism and format used to persist settings in Chainsaw is
subject to change.  If you are experiencing problems displaying events in Chainsaw, please
delete everything in the $user.dir/.chainsaw directory and restart Chainsaw.
 <br>
 <h1>2.1</h1>
+<h2>2 Oct 2011</h2>
+<ul>
+<li>Added persistent "always display" expression support (button below the logger tree).
 The 'always display' expression overrides hidden loggers and the hidden expression but not
the refine focus filtering mechanism.  Often used with expressions like 'exception exists
|| level > warn' to ensure errors and exceptions are not filtered out due to the hidden
expression or hidden logger mechanism. </li>
+</ul>
 <h2>11 Nov 2010</h2>
 <ul>
 <li>Added per-tab preference to not use a search match color in the primary table</li>



Mime
View raw message