logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r917906 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ChainsawColumns.java ChainsawConstants.java ChainsawCyclicBufferTableModel.java LogPanel.java TableColorizingRenderer.java
Date Tue, 02 Mar 2010 08:01:45 GMT
Author: sdeboy
Date: Tue Mar  2 08:01:44 2010
New Revision: 917906

URL: http://svn.apache.org/viewvc?rev=917906&view=rev
Log:
MDC properties are case sensitive, so make log4j.marker lowercase
Fix problems loading columns if version is old

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawColumns.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.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/ChainsawColumns.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawColumns.java?rev=917906&r1=917905&r2=917906&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawColumns.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawColumns.java Tue
Mar  2 08:01:44 2010
@@ -37,7 +37,7 @@
 
   static {
     columnNames.add(ChainsawConstants.LOGGER_COL_NAME);
-    columnNames.add(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+    columnNames.add(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE.toUpperCase()); //add
uppercase col name
     columnNames.add(ChainsawConstants.TIMESTAMP_COL_NAME);
     columnNames.add(ChainsawConstants.LEVEL_COL_NAME);
     columnNames.add(ChainsawConstants.THREAD_COL_NAME);

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java?rev=917906&r1=917905&r2=917906&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
Tue Mar  2 08:01:44 2010
@@ -57,7 +57,7 @@
 
   //COLUMN NAMES
   static final String LOGGER_COL_NAME = "LOGGER";
-  static final String LOG4J_MARKER_COL_NAME = "LOG4J.MARKER";
+  static final String LOG4J_MARKER_COL_NAME_LOWERCASE = "log4j.marker"; //properties are
case-sensitive-using lowercase for easier entry
   static final String TIMESTAMP_COL_NAME = "TIMESTAMP";
   static final String LEVEL_COL_NAME = "LEVEL";
   static final String THREAD_COL_NAME = "THREAD";

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=917906&r1=917905&r2=917906&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
Tue Mar  2 08:01:44 2010
@@ -410,7 +410,7 @@
       return event.getLevel();
 
     case ChainsawColumns.INDEX_LOG4J_MARKER_COL_NAME:
-      return event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+      return event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE);
 
     case ChainsawColumns.INDEX_LOGGER_COL_NAME:
       return event.getLoggerName();
@@ -630,7 +630,7 @@
       return true;
     }
 
-    if (getColumnName(columnIndex).equals(ChainsawConstants.LOG4J_MARKER_COL_NAME)) {
+    if (getColumnName(columnIndex).toLowerCase().equals(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE))
{
       return true;
     }
 

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=917906&r1=917905&r2=917906&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 Tue Mar 
2 08:01:44 2010
@@ -241,7 +241,7 @@
   static final String TABLE_COLUMN_ORDER = "table.columns.order";
   static final String TABLE_COLUMN_WIDTHS = "table.columns.widths";
   static final String COLORS_EXTENSION = ".colors";
-  private static final int LOG_PANEL_SERIALIZATION_VERSION_NUMBER = 1;
+  private static final int LOG_PANEL_SERIALIZATION_VERSION_NUMBER = 2; //increment when format
changes
   private int previousLastIndex = -1;
   private final DateFormat timestampExpressionFormat = new SimpleDateFormat(Constants.TIMESTAMP_RULE_FORMAT);
   private final Logger logger = LogManager.getLogger(LogPanel.class);
@@ -1038,7 +1038,7 @@
             
         }
     });
-    findMarkerRule = ExpressionRule.getRule("prop." + ChainsawConstants.LOG4J_MARKER_COL_NAME
+ " exists");
+    findMarkerRule = ExpressionRule.getRule("prop." + ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE
+ " exists");
         
     tableModel.addTableModelListener(new TableModelListener() {
 		public void tableChanged(TableModelEvent e) {
@@ -1591,45 +1591,66 @@
     File xmlFile = new File(SettingsManager.getInstance()
                 .getSettingsDirectory(), URLEncoder.encode(identifier) + ".xml");
 
-        if (xmlFile.exists()) {
-            XStream stream = buildXStreamForLogPanelPreference();
-            ObjectInputStream in = null;
+    if (xmlFile.exists()) {
+        XStream stream = buildXStreamForLogPanelPreference();
+        ObjectInputStream in = null;
+        try {
+            FileReader r = new FileReader(xmlFile);
+            in = stream.createObjectInputStream(r);
+            LogPanelPreferenceModel storedPrefs = (LogPanelPreferenceModel)in.readObject();
+            int lowerPanelDividerLocation = in.readInt();
+            int treeDividerLocation = in.readInt();
+            String conversionPattern = in.readObject().toString();
+            Point p = (Point)in.readObject();
+            Dimension d = (Dimension)in.readObject();
+            //this version number is checked to identify whether there is a Vector comming
next
+            int versionNumber = 0;
             try {
-            	FileReader r = new FileReader(xmlFile);
-            	in = stream.createObjectInputStream(r);
-            	
-                LogPanelPreferenceModel storedPrefs = (LogPanelPreferenceModel)in.readObject();
-                String columnOrder = event.getSetting(TABLE_COLUMN_ORDER);
-                preferenceModel.apply(storedPrefs);
-
-                //update prefModel columns to include defaults
-                int index = 0;
-                StringTokenizer tok = new StringTokenizer(columnOrder, ",");
-                while (tok.hasMoreElements()) {
-                  String element = tok.nextElement().toString().trim().toUpperCase();
-                  TableColumn column = new TableColumn(index++);
-                  column.setHeaderValue(element);
-                  preferenceModel.addColumn(column);
-                }
+                versionNumber = in.readInt();
+            } catch (EOFException eof){
+            }
 
-                TableColumnModel columnModel = table.getColumnModel();
-                //remove previous columns
-                while (columnModel.getColumnCount() > 0) {
-                	columnModel.removeColumn(columnModel.getColumn(0));
-                }
-                //add visible column order columns
-                for (Iterator iter = preferenceModel.getVisibleColumnOrder().iterator();iter.hasNext();)
{
-                	TableColumn col = (TableColumn)iter.next();
-                	columnModel.addColumn(col);
+            Vector savedVector;
+            //read the vector only if the version number is greater than 0. higher version
numbers can be
+            //used in the future to save more data structures
+            if (versionNumber > 0) {
+                savedVector = (Vector) in.readObject();
+                for(int i = 0 ; i < savedVector.size() ; i++){
+                    Object item = savedVector.get(i);
+                    if(!filterExpressionVector.contains(item)){
+                        filterExpressionVector.add(item);
+                    }
                 }
+                if (versionNumber > 1) {
+                    //update prefModel columns to include defaults
+                    int index = 0;
+                    String columnOrder = event.getSetting(TABLE_COLUMN_ORDER);
+                    StringTokenizer tok = new StringTokenizer(columnOrder, ",");
+                    while (tok.hasMoreElements()) {
+                      String element = tok.nextElement().toString().trim().toUpperCase();
+                      TableColumn column = new TableColumn(index++);
+                      column.setHeaderValue(element);
+                      preferenceModel.addColumn(column);
+                    }
 
-                try {
-                	//may be panel configs that don't have these values
-                lowerPanel.setDividerLocation(in.readInt());
-                nameTreeAndMainPanelSplit.setDividerLocation(in.readInt());
-                detailLayout.setConversionPattern(in.readObject().toString());
-                Point p = (Point)in.readObject();
-                Dimension d = (Dimension)in.readObject();
+                    TableColumnModel columnModel = table.getColumnModel();
+                    //remove previous columns
+                    while (columnModel.getColumnCount() > 0) {
+                        columnModel.removeColumn(columnModel.getColumn(0));
+                    }
+                    //add visible column order columns
+                    for (Iterator iter = preferenceModel.getVisibleColumnOrder().iterator();iter.hasNext();)
{
+                        TableColumn col = (TableColumn)iter.next();
+                        columnModel.addColumn(col);
+                    }
+                    preferenceModel.apply(storedPrefs);
+                } else {
+                    loadDefaultColumnSettings(event);
+                }
+                //may be panel configs that don't have these values
+                lowerPanel.setDividerLocation(lowerPanelDividerLocation);
+                nameTreeAndMainPanelSplit.setDividerLocation(treeDividerLocation);
+                detailLayout.setConversionPattern(conversionPattern);
                 if (p.x != 0 && p.y != 0) {
                     undockedFrame.setLocation(p.x, p.y);
                     undockedFrame.setSize(d);
@@ -1637,44 +1658,24 @@
                     undockedFrame.setLocation(0, 0);
                     undockedFrame.setSize(new Dimension(1024, 768));
                 }
-
-                int versionNumber = 0;
-                Vector savedVector;
-
-                //this version number is checked to identify whether there is a Vector comming
next
-                try {
-                    versionNumber = in.readInt();
-                } catch (EOFException eof){
-                }
-
-                //read the vector only if the version number is greater than 0. higher version
numbers can be
-                //used in the future to save more data structures
-                if (versionNumber > 0){
-                    savedVector = (Vector) in.readObject();
-                    for(int i = 0 ; i < savedVector.size() ; i++){
-                        Object item = savedVector.get(i);
-                        if(!filterExpressionVector.contains(item)){
-                            filterExpressionVector.add(item);
-                        }
-                    }
-                }
-
-                } catch (EOFException eof){
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                // TODO need to log this..
-            } finally {
-            	if (in != null) {
-            		try {
-            			in.close();
-            		} catch (IOException ioe) {}
-            	}
+            } else {
+                loadDefaultColumnSettings(event);
             }
-        } else {
+        } catch (Exception e) {
+            e.printStackTrace();
             loadDefaultColumnSettings(event);
-		}
-        
+            // TODO need to log this..
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException ioe) {}
+            }
+        }
+    } else {
+        loadDefaultColumnSettings(event);
+    }
+
     logTreePanel.ignore(preferenceModel.getHiddenLoggers());
 
     //first attempt to load encoded file
@@ -2553,18 +2554,18 @@
     }
 
     public void clearAllMarkers() {
-        tableModel.removePropertyFromEvents(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+        tableModel.removePropertyFromEvents(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE);
     }
 
     public void toggleMarker() {
         int row = table.getSelectedRow();
         if (row != -1) {
           LoggingEvent event = tableModel.getRow(row);
-          Object marker = event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+          Object marker = event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE);
           if (marker == null) {
-              event.setProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME, "set");
+              event.setProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE, "set");
           } else {
-              event.removeProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+              event.removeProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE);
           }
           //if marker -was- null, it no longer is (may need to add the column)
           tableModel.fireRowUpdated(row, (marker == null));
@@ -2695,11 +2696,11 @@
               int row = table.rowAtPoint(evt.getPoint());
               if (row != -1) {
                 LoggingEvent event = tableModel.getRow(row);
-                Object marker = event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+                Object marker = event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE);
                 if (marker == null) {
-                    event.setProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME, "set");
+                    event.setProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE,
"set");
                 } else {
-                    event.removeProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+                    event.removeProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE);
                 }
                 //if marker -was- null, it no longer is (may need to add the column)
                 tableModel.fireRowUpdated(row, (marker == null));
@@ -2772,7 +2773,7 @@
           (column.getModelIndex() + 1) == ChainsawColumns.INDEX_THROWABLE_COL_NAME) {
           column.setCellEditor(throwableRenderPanel);
         }
-        if (column.getHeaderValue().toString().equals(ChainsawConstants.LOG4J_MARKER_COL_NAME))
{
+        if (column.getHeaderValue().toString().toLowerCase().equals(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE))
{
           column.setCellEditor(markerCellEditor);
         }
       }
@@ -2923,9 +2924,9 @@
         public boolean stopCellEditing()
         {
             if (textField.getText().trim().equals("")) {
-                currentEvent.removeProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME);
+                currentEvent.removeProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE);
             } else {
-                currentEvent.setProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME, textField.getText());
+                currentEvent.setProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE,
textField.getText());
             }
             ChangeEvent event = new ChangeEvent(table);
             for (Iterator iter = cellEditorListeners.iterator();iter.hasNext();) {
@@ -2955,7 +2956,7 @@
         public Component getTableCellEditorComponent(JTable table, Object value, boolean
isSelected, int row, int column)
         {
             currentEvent = tableModel.getRow(row);
-            textField.setText(currentEvent.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME));
+            textField.setText(currentEvent.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE));
             textField.selectAll();
             return textField;
         }

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=917906&r1=917905&r2=917906&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
Tue Mar  2 08:01:44 2010
@@ -195,7 +195,7 @@
     }
     //set the 'marker' icon next to the zeroth column if marker is set
     if (col == 0) {
-      if (event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME) != null) {
+      if (event.getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE) != null) {
         c.setIcon(markerIcon);
       } else {
         //only null out the column if it's not the level field



Mime
View raw message