jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1339882 - in /jmeter/trunk: bin/ src/core/org/apache/jmeter/gui/ src/core/org/apache/jmeter/gui/action/ src/core/org/apache/jmeter/images/ src/jorphan/org/apache/jorphan/logging/ xdocs/
Date Thu, 17 May 2012 22:09:04 GMT
Author: pmouawad
Date: Thu May 17 22:09:03 2012
New Revision: 1339882

URL: http://svn.apache.org/viewvc?rev=1339882&view=rev
Log:
Bug 42784 - Show the number of errors logged in the GUI

Added:
    jmeter/trunk/src/core/org/apache/jmeter/images/warning.png   (with props)
Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Clear.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/logging/LoggingManager.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1339882&r1=1339881&r2=1339882&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Thu May 17 22:09:03 2012
@@ -124,6 +124,11 @@ jmeter.laf.mac=System
 # LoggerPanel display
 # default to false
 #jmeter.loggerpanel.display=false
+
+# Error/Fatal Log count display
+# default to false
+#jmeter.errorscounter.display=true
+
 # Max characters kept in LoggerPanel, default to 80000 chars
 # O means no limit
 #jmeter.loggerpanel.maxlength=80000

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java?rev=1339882&r1=1339881&r2=1339882&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java Thu May 17 22:09:03 2012
@@ -42,6 +42,7 @@ import java.io.IOException;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.swing.BorderFactory;
 import javax.swing.Box;
@@ -74,6 +75,7 @@ import org.apache.jmeter.gui.tree.JMeter
 import org.apache.jmeter.gui.tree.JMeterTreeListener;
 import org.apache.jmeter.gui.util.JMeterMenuBar;
 import org.apache.jmeter.gui.util.JMeterToolBar;
+import org.apache.jmeter.samplers.Clearable;
 import org.apache.jmeter.samplers.Remoteable;
 import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.testelement.TestListener;
@@ -81,14 +83,17 @@ import org.apache.jmeter.threads.JMeterC
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.ComponentUtil;
 import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.LogEvent;
+import org.apache.log.LogTarget;
 import org.apache.log.Logger;
+import org.apache.log.Priority;
 
 /**
  * The main JMeter frame, containing the menu bar, test tree, and an area for
  * JMeter component GUIs.
  *
  */
-public class MainFrame extends JFrame implements TestListener, Remoteable, DropTargetListener
{
+public class MainFrame extends JFrame implements TestListener, Remoteable, DropTargetListener,
Clearable {
 
     private static final long serialVersionUID = 240L;
 
@@ -108,6 +113,10 @@ public class MainFrame extends JFrame im
     private static final boolean DISPLAY_LOGGER_PANEL =
             JMeterUtils.getPropDefault("jmeter.loggerpanel.display", false); // $NON-NLS-1$
 
+    // Allow display/hide Log Error/Fatal counter
+    private static final boolean DISPLAY_ERROR_FATAL_COUNTER =
+            JMeterUtils.getPropDefault("jmeter.errorscounter.display", true); // $NON-NLS-1$
+
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     /** The menu bar. */
@@ -131,6 +140,9 @@ public class MainFrame extends JFrame im
     /** An image which is displayed when a test is not currently running. */
     private ImageIcon stoppedIcon = JMeterUtils.getImage("thread.disabled.gif");// $NON-NLS-1$
 
+    /** An image which is displayed to indicate FATAL, ERROR or WARNING. */
+    private ImageIcon warningIcon = JMeterUtils.getImage("warning.png");// $NON-NLS-1$
+
     /** The button used to display the running/stopped image. */
     private JButton runningIndicator;
 
@@ -152,6 +164,19 @@ public class MainFrame extends JFrame im
     private JMeterToolBar toolbar;
 
     /**
+     * Indicator for Log errors and Fatals
+     */
+    private JButton warnIndicator;
+    /**
+     * Counter
+     */
+    private JLabel errorsOrFatalsLabel;
+    /**
+     * LogTarget that receives ERROR or FATAL
+     */
+    private ErrorsAndFatalsCounterLogTarget errorsAndFatalsCounterLogTarget;
+
+    /**
      * Create a new JMeter frame.
      *
      * @param actionHandler
@@ -173,6 +198,11 @@ public class MainFrame extends JFrame im
         totalThreads = new JLabel("0"); // $NON-NLS-1$
         activeThreads = new JLabel("0"); // $NON-NLS-1$
 
+        warnIndicator = new JButton(warningIcon);
+        warnIndicator.setMargin(new Insets(0, 0, 0, 0));
+        warnIndicator.setBorder(BorderFactory.createEmptyBorder());
+        errorsOrFatalsLabel = new JLabel("0"); // $NON-NLS-1$
+
         tree = makeTree(treeModel, treeListener);
 
         GuiPackage.getInstance().setMainFrame(this);
@@ -327,7 +357,7 @@ public class MainFrame extends JFrame im
             }
         });
     }
-
+    
     public void setMainPanel(JComponent comp) {
         mainPanel.setViewportView(comp);
     }
@@ -424,7 +454,19 @@ public class MainFrame extends JFrame im
             topAndDown.setDividerSize(0);
         }
         mainPanel = createMainPanel();
+
         logPanel = createLoggerPanel();
+        if(DISPLAY_ERROR_FATAL_COUNTER) {
+            errorsAndFatalsCounterLogTarget = new ErrorsAndFatalsCounterLogTarget();
+            LoggingManager.addLogTargetToRootLogger(new LogTarget[]{
+                logPanel,
+                errorsAndFatalsCounterLogTarget
+                 });
+        } else {
+            LoggingManager.addLogTargetToRootLogger(new LogTarget[]{
+                    logPanel
+                     });            
+        }
         
         topAndDown.setTopComponent(mainPanel);
         topAndDown.setBottomComponent(logPanel);
@@ -482,6 +524,12 @@ public class MainFrame extends JFrame im
 
         toolPanel.add(Box.createRigidArea(new Dimension(10, 15)));
         toolPanel.add(Box.createGlue());
+        
+        if(DISPLAY_ERROR_FATAL_COUNTER) {
+            toolPanel.add(errorsOrFatalsLabel);
+            toolPanel.add(warnIndicator);
+            toolPanel.add(Box.createRigidArea(new Dimension(10, 15)));
+        }
         toolPanel.add(activeThreads);
         toolPanel.add(new JLabel(" / "));
         toolPanel.add(totalThreads);
@@ -519,7 +567,6 @@ public class MainFrame extends JFrame im
         LoggerPanel loggerPanel = new LoggerPanel();
         loggerPanel.setMinimumSize(new Dimension(0, 100));
         loggerPanel.setPreferredSize(new Dimension(0, 150));
-        LoggingManager.addLogTargetToRootLogger(loggerPanel);
         GuiPackage guiInstance = GuiPackage.getInstance();
         guiInstance.setLoggerPanel(loggerPanel);
         guiInstance.getMenuItemLoggerPanel().getModel().setSelected(DISPLAY_LOGGER_PANEL);
@@ -677,4 +724,39 @@ public class MainFrame extends JFrame im
     public void dropActionChanged(DropTargetDragEvent dtde) {
         // NOOP
     }
+    
+    /**
+     * 
+     */
+    public final class ErrorsAndFatalsCounterLogTarget implements LogTarget, Clearable {
+        public AtomicInteger errorOrFatal = new AtomicInteger(0);
+
+        public void processEvent(LogEvent event) {
+            if(event.getPriority().equals(Priority.ERROR) ||
+                    event.getPriority().equals(Priority.FATAL_ERROR)) {
+                final int newValue = errorOrFatal.incrementAndGet();
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
+                        errorsOrFatalsLabel.setText(Integer.toString(newValue));
+                    }
+                });
+            }
+        }  
+        
+        public void clearData() {
+            errorOrFatal.set(0);
+            SwingUtilities.invokeLater(new Runnable() {
+                public void run() {
+                    errorsOrFatalsLabel.setText(Integer.toString(errorOrFatal.get()));
+                }
+            });
+        }
+    }
+
+    
+    public void clearData() {
+        if(DISPLAY_ERROR_FATAL_COUNTER) {
+            errorsAndFatalsCounterLogTarget.clearData();
+        }
+    }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Clear.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Clear.java?rev=1339882&r1=1339881&r2=1339882&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Clear.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Clear.java Thu May 17 22:09:03 2012
@@ -65,6 +65,7 @@ public class Clear implements Command {
             JMeterGUIComponent guiComp = guiPackage.getCurrentGui();
             guiComp.clearGui();
         } else {
+            guiPackage.getMainFrame().clearData();
             for (JMeterTreeNode node : guiPackage.getTreeModel().getNodesOfType(Clearable.class))
{
                 JMeterGUIComponent guiComp = guiPackage.getGui(node.getTestElement());
                 if (guiComp instanceof Clearable){

Added: jmeter/trunk/src/core/org/apache/jmeter/images/warning.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/images/warning.png?rev=1339882&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jmeter/trunk/src/core/org/apache/jmeter/images/warning.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/logging/LoggingManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/logging/LoggingManager.java?rev=1339882&r1=1339881&r2=1339882&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/logging/LoggingManager.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/logging/LoggingManager.java Thu May 17 22:09:03
2012
@@ -348,12 +348,14 @@ public final class LoggingManager {
     }
 
     /**
-     * Add logTarget to root logger
+     * Add logTargets to root logger
      * FIXME What's the clean way to add a LogTarget afterwards ?
-     * @param logTarget LogTarget
+     * @param logTargets LogTarget array
      */
-    public static void addLogTargetToRootLogger(LogTarget logTarget) {
-        Hierarchy.getDefaultHierarchy().getRootLogger().setLogTargets(
-                new LogTarget[]{target, logTarget});
+    public static void addLogTargetToRootLogger(LogTarget[] logTargets) {
+        LogTarget[] newLogTargets = new LogTarget[logTargets.length+1];
+        System.arraycopy(logTargets, 0, newLogTargets, 1, logTargets.length);
+        newLogTargets[0] = target;
+        Hierarchy.getDefaultHierarchy().getRootLogger().setLogTargets(newLogTargets);
     }
-}
+}
\ No newline at end of file

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1339882&r1=1339881&r2=1339882&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Thu May 17 22:09:03 2012
@@ -289,6 +289,7 @@ Graph Full Results Listener has been rem
 <li>Bug 52941 - Improvements of HTML report design generated by JMeter Ant task extra</li>
 <li>Bug 53042 - Introduce a new method in Sampler interface to allow Sampler to decide
wether a config element applies to Sampler</li>
 <li>Bug 52771 - Documentation : Added RSS feed on JMeter Home page under link "Subscribe
to What's New"</li>
+<li>Bug 42784 - Show the number of errors logged in the GUI</li>
 </ul>
 
 <h2>Non-functional changes</h2>



Mime
View raw message