logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r998011 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ChainsawCyclicBufferTableModel.java Generator.java LogPanel.java TableColorizingRenderer.java
Date Fri, 17 Sep 2010 07:41:29 GMT
Author: sdeboy
Date: Fri Sep 17 07:41:28 2010
New Revision: 998011

URL: http://svn.apache.org/viewvc?rev=998011&view=rev
Log:
Layout improvements
 - You can now click anywhere in the throwable column (only if the column contains an exception)
to get the throwable dialog containing the stack trace
 - Updated tutorial event generator to include throwable info
 - Added a left indent of 6 to textpanes used to render the table to provide some whitespace
between text entries in the columns

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/Generator.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java?rev=998011&r1=998010&r2=998011&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
Fri Sep 17 07:41:28 2010
@@ -765,11 +765,6 @@ class ChainsawCyclicBufferTableModel ext
    * @see javax.swing.table.TableModel#isCellEditable(int, int)
    */
   public boolean isCellEditable(int rowIndex, int columnIndex) {
-    switch (columnIndex + 1) {
-    case ChainsawColumns.INDEX_THROWABLE_COL_NAME:
-      return true;
-    }
-
     if (getColumnName(columnIndex).toLowerCase().equals(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE))
{
       return true;
     }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/Generator.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/Generator.java?rev=998011&r1=998010&r2=998011&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/Generator.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/Generator.java Fri Sep
17 07:41:28 2010
@@ -17,13 +17,18 @@
 
 package org.apache.log4j.chainsaw;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.log4j.MDC;
 import org.apache.log4j.NDC;
 import org.apache.log4j.helpers.Constants;
 import org.apache.log4j.plugins.Receiver;
+import org.apache.log4j.spi.LocationInfo;
 import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.ThrowableInformation;
 
 
 /**
@@ -51,11 +56,13 @@ public class Generator extends Receiver 
 
   private LoggingEvent createEvent(
     Level level, Logger logger, String msg, Throwable t) {
+      ThrowableInformation ti = new ThrowableInformation(t);
+      Map properties = new HashMap();
+      properties.put(Constants.APPLICATION_KEY, getName());
+      properties.put(Constants.HOSTNAME_KEY, "localhost");
+      LocationInfo li = new LocationInfo("file", logger.getClass().getName(), "method", "123");
     LoggingEvent e = new LoggingEvent(
-        logger.getClass().getName(), logger, level, msg, t);
-    e.setProperty(Constants.APPLICATION_KEY, getName());
-    e.setProperty(Constants.HOSTNAME_KEY, "localhost");
-
+        logger.getClass().getName(), logger, System.currentTimeMillis(), level, msg, "Thread=1",
ti, "NDC value", li, properties);
     return e;
   }
 

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=998011&r1=998010&r2=998011&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 Fri Sep 17
07:41:28 2010
@@ -220,7 +220,6 @@ public class LogPanel extends DockablePa
   private final JSortTable table;
   private final TableColorizingRenderer renderer;
   private final EventContainer tableModel;
-  private final ThrowableRenderPanel throwableRenderPanel;
   private final JEditorPane detail;
   private final JSplitPane lowerPanel;
   private final DetailPaneUpdater detailPaneUpdater;
@@ -901,7 +900,6 @@ public class LogPanel extends DockablePa
     /*
      * Throwable popup
      */
-    throwableRenderPanel = new ThrowableRenderPanel();
     markerCellEditor = new MarkerCellEditor();
 
     final JDialog detailDialog = new JDialog((JFrame) null, true);
@@ -916,39 +914,36 @@ public class LogPanel extends DockablePa
 
     detailDialog.pack();
 
-    throwableRenderPanel.addActionListener(
-      new ActionListener() {
-        public void actionPerformed(ActionEvent e) {
-          ExtendedLoggingEvent event = tableModel.getRow(table.getSelectedRow());
-          detailDialog.setTitle(
-            table.getColumnName(table.getSelectedColumn()) + " detail...");
-          if (event == null) {
-              detailArea.setText("");
-          } else {
+    table.addMouseListener(new MouseAdapter() {
+        public void mouseClicked(MouseEvent e)
+        {
+            TableColumn column = table.getColumnModel().getColumn(table.columnAtPoint(e.getPoint()));
+            if (!column.getHeaderValue().toString().toUpperCase().equals(ChainsawColumns.getColumnName(ChainsawColumns.INDEX_THROWABLE_COL_NAME)))
{
+                return;
+            }
+
+            ExtendedLoggingEvent event = tableModel.getRow(table.getSelectedRow());
+
             //throwable string representation may be a length-one empty array
             String[] ti = event.getThrowableStrRep();
             if (ti != null && ti.length > 0 && (!(ti.length == 1 &&
ti[0].equals("")))) {
-                StringBuffer buf = new StringBuffer();
-                buf.append(event.getMessage());
-                buf.append("\n");
-                for (int i = 0; i < ti.length; i++) {
-                  buf.append(ti[i]).append("\n    ");
-                }
-
-                detailArea.setText(buf.toString());
-              } else {
-                //no exception
-                detailArea.setText("");
-              }
-          }
+                 detailDialog.setTitle(table.getColumnName(table.getSelectedColumn()) + "
detail...");
+                  StringBuffer buf = new StringBuffer();
+                  buf.append(event.getMessage());
+                  buf.append("\n");
+                  for (int i = 0; i < ti.length; i++) {
+                    buf.append(ti[i]).append("\n    ");
+                  }
 
-          SwingHelper.invokeOnEDT(new Runnable() {
-              public void run() {
-                centerAndSetVisible(detailDialog);
-              }
-            });
+                  detailArea.setText(buf.toString());
+                  SwingHelper.invokeOnEDT(new Runnable() {
+                    public void run() {
+                      centerAndSetVisible(detailDialog);
+                    }
+                  });
+                }
         }
-      });
+    });
 
     /*
      * We listen for new Key's coming in so we can get them automatically
@@ -3130,8 +3125,8 @@ public class LogPanel extends DockablePa
     }
 
     /**
-     * If a new column was added to the display and that column was the exception column,
-     * set the cell editor to the throwablerenderer
+     * If a new column was added to the display and that column was the marker column,
+     * set the cell editor to the markerCellEditor
      *
      * @param e
      */
@@ -3141,10 +3136,6 @@ public class LogPanel extends DockablePa
       while (enumeration.hasMoreElements()) {
         TableColumn column = (TableColumn) enumeration.nextElement();
 
-        if (
-          (column.getModelIndex() + 1) == ChainsawColumns.INDEX_THROWABLE_COL_NAME) {
-          column.setCellEditor(throwableRenderPanel);
-        }
         if (column.getHeaderValue().toString().toLowerCase().equals(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE))
{
           column.setCellEditor(markerCellEditor);
         }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java?rev=998011&r1=998010&r2=998011&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
Fri Sep 17 07:41:28 2010
@@ -116,6 +116,7 @@ public class TableColorizingRenderer ext
   private boolean useRelativeTimesToPrevious;
   private EventContainer eventContainer;
   private LogPanelPreferenceModel logPanelPreferenceModel;
+  private SimpleAttributeSet insetAttributeSet;
 
     /**
    * Creates a new TableColorizingRenderer object.
@@ -134,6 +135,8 @@ public class TableColorizingRenderer ext
     boldAttributeSet = new SimpleAttributeSet();
     StyleConstants.setBold(boldAttributeSet, true);
 
+    insetAttributeSet = new SimpleAttributeSet();
+    StyleConstants.setLeftIndent(insetAttributeSet, 6);
     //throwable col may have a tab..if so, render the tab as col zero
     int pos = 0;
     int align = TabStop.ALIGN_LEFT;
@@ -155,10 +158,10 @@ public class TableColorizingRenderer ext
 
     multiLineTextPane.setEditable(false);
     multiLineTextPane.setFont(levelTextPane.getFont());
-    Insets leftRightInsets = new Insets(0, 5, 0, 5);
-    multiLineTextPane.setMargin(leftRightInsets);
-    singleLineTextPane.setMargin(leftRightInsets);
-    levelTextPane.setMargin(leftRightInsets);
+
+    multiLineTextPane.setParagraphAttributes(insetAttributeSet, false);
+    singleLineTextPane.setParagraphAttributes(insetAttributeSet, false);
+    levelTextPane.setParagraphAttributes(insetAttributeSet, false);
   }
 
   public void setToolTipsVisible(boolean toolTipsVisible) {



Mime
View raw message