logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw TableColorizingRenderer.java ChainsawAppenderHandler.java ChainsawConstants.java DefaultSortTableModel.java DisplayFilter.java
Date Fri, 02 May 2003 04:19:28 GMT
sdeboy      2003/05/01 21:19:27

  Modified:    src/java/org/apache/log4j/chainsaw
                        TableColorizingRenderer.java
                        ChainsawAppenderHandler.java ChainsawConstants.java
                        DefaultSortTableModel.java DisplayFilter.java
  Log:
  Removed use of deprecated date constructor.  Added ID field as property during return of
events for save, reuse ID if found as property (makes events identical from save/load, including
ID)
  
  Revision  Changes    Path
  1.2       +2 -1      jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
  
  Index: TableColorizingRenderer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TableColorizingRenderer.java	28 Apr 2003 05:44:31 -0000	1.1
  +++ TableColorizingRenderer.java	2 May 2003 04:19:26 -0000	1.2
  @@ -53,6 +53,7 @@
   import java.awt.Component;
   
   import java.text.DateFormat;
  +import java.text.SimpleDateFormat;
   
   import java.util.Date;
   import java.util.Vector;
  @@ -71,7 +72,7 @@
   public class TableColorizingRenderer extends DefaultTableCellRenderer
     implements FilterChangedListener {
     private static final DateFormat DATE_FORMATTER =
  -    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
  +    new SimpleDateFormat(ChainsawConstants.DATETIME_FORMAT);
     private ColorFilter colorFilter;
     private JTable table;
     private Color background = new Color(255, 255, 254);
  
  
  
  1.4       +2 -2      jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java
  
  Index: ChainsawAppenderHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ChainsawAppenderHandler.java	30 Apr 2003 08:44:50 -0000	1.3
  +++ ChainsawAppenderHandler.java	2 May 2003 04:19:26 -0000	1.4
  @@ -145,7 +145,7 @@
   
       while (iter.hasNext()) {
         if (MDC.length() != 0) {
  -        MDC.append(", ");
  +        MDC.append(",");
         }
   
         String propName = (String) iter.next();
  @@ -164,7 +164,7 @@
   
         while (iter2.hasNext()) {
           if (prop.length() != 0) {
  -          prop.append(", ");
  +          prop.append(",");
           }
   
           String propName = (String) iter2.next();
  
  
  
  1.2       +3 -0      jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawConstants.java
  
  Index: ChainsawConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChainsawConstants.java	1 May 2003 02:37:24 -0000	1.1
  +++ ChainsawConstants.java	2 May 2003 04:19:26 -0000	1.2
  @@ -42,7 +42,10 @@
     static final String FATAL_LEVEL = "FATAL";
     static final String LOG4J_APP_KEY = "log4japp";
     static final String LOG4J_MACHINE_KEY = "log4jmachinename";
  +  static final String LOG4J_ID_KEY = "log4jid";
     static final String UNKNOWN_TAB_NAME = "Unknown";
     static final String GLOBAL_MATCH = "*";
     static final String DETAIL_CONTENT_TYPE = "text/html";
  +  
  +  static final String DATETIME_FORMAT = "EEE MMM dd HH:mm:ss z yyyy";
   }
  
  
  
  1.3       +46 -4     jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/DefaultSortTableModel.java
  
  Index: DefaultSortTableModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/DefaultSortTableModel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultSortTableModel.java	1 May 2003 04:50:25 -0000	1.2
  +++ DefaultSortTableModel.java	2 May 2003 04:19:26 -0000	1.3
  @@ -49,6 +49,9 @@
   
   package org.apache.log4j.chainsaw;
   
  +import java.text.DateFormat;
  +import java.text.ParseException;
  +import java.text.SimpleDateFormat;
   import java.util.Collections;
   import java.util.Date;
   import java.util.HashMap;
  @@ -79,7 +82,9 @@
     private boolean currentSortAscending;
     private boolean sortEnabled;
     private DisplayFilter displayFilter;
  -
  +  private static final DateFormat DATE_FORMATTER =
  +    new SimpleDateFormat(ChainsawConstants.DATETIME_FORMAT);
  +    
     //a map of events keyed on ID (order received)
     private HashMap unfilteredEvents = new HashMap();
     private Vector allColumnNames;
  @@ -351,6 +356,7 @@
       String fileName = "";
       String lineNumber = "";
       Hashtable properties = null;
  +    boolean hadIDProperty=false;
   
   	String value=null;
       while (iter.hasNext()) {
  @@ -362,8 +368,14 @@
   	      logger = Logger.getLogger(value);
         }
         if (column.equalsIgnoreCase(ChainsawConstants.TIMESTAMP_COL_NAME)) {      
  -	      timeStamp = new Date(value).getTime();
  +      	try {
  +		  timeStamp = DATE_FORMATTER.parse(value).getTime();
  +      	} catch (ParseException pe) {
  +      		pe.printStackTrace();
  +      		//ignore...leave as 0L
  +      	}
         }
  +
         if (column.equalsIgnoreCase(ChainsawConstants.LEVEL_COL_NAME)) {      
   	      level=Level.toLevel(value);
         }
  @@ -405,10 +417,18 @@
         	StringTokenizer t=new StringTokenizer(value, ",");
         	while (t.hasMoreElements()) {
   			StringTokenizer t2=new StringTokenizer(t.nextToken(), "=");
  -      		properties.put(t2.nextToken(), t2.nextToken());
  +			String propertyName=t2.nextToken();
  +			if (propertyName.equalsIgnoreCase(ChainsawConstants.LOG4J_ID_KEY)) {
  +				hadIDProperty=true;
  +			}
  +      		properties.put(propertyName, t2.nextToken());
         	}
         }
       }
  +    //if log4jid property did not exist, set it (will be used during reconstruction)
  +    if (!hadIDProperty) {
  +    	properties.put(ChainsawConstants.LOG4J_ID_KEY, ID.toString());
  +    }
   	return new LoggingEvent(logger.getName(), logger, timeStamp, level, threadName, message,
ndc, mdc,
           exception, className, methodName, fileName, lineNumber, properties);
     }
  @@ -416,7 +436,29 @@
     public boolean isAddRow(Vector v) {
       synchronized (getDataVector()) {
         //set the last field to the 'unfilteredevents size + 1 - an ID based on reception
order
  -      Integer thisInt = new Integer(unfilteredEvents.size() + 1);
  +      int propertiesIndex=allColumnNames.indexOf(ChainsawConstants.PROPERTIES_COL_NAME);
  +      String props=(String)v.get(propertiesIndex);
  +      Integer thisInt=null;
  +      if (props.indexOf(ChainsawConstants.LOG4J_ID_KEY) > -1) {
  +      	StringBuffer newProps=new StringBuffer();
  +      	StringTokenizer t=new StringTokenizer(props, ",");
  +      	while (t.hasMoreElements()) {
  +			StringTokenizer t2=new StringTokenizer(t.nextToken(), "=");
  +			String propertyName=t2.nextToken();
  +			if (propertyName.equalsIgnoreCase(ChainsawConstants.LOG4J_ID_KEY)) {
  +				thisInt=new Integer(t2.nextToken());
  +			} else {
  +				newProps.append(propertyName);
  +				newProps.append("=");
  +				newProps.append(t2.nextToken());
  +			}
  +      	}
  +      	//strip off the ID property - not needed now that it's reloaded
  +      	v.set(propertiesIndex, newProps.toString());
  +      }
  +      if (thisInt==null) {
  +      	thisInt = new Integer(unfilteredEvents.size() + 1);
  +      }
         v.add(thisInt);
         unfilteredEvents.put(thisInt, v);
   
  
  
  
  1.3       +4 -4      jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/DisplayFilter.java
  
  Index: DisplayFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/DisplayFilter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DisplayFilter.java	29 Apr 2003 16:21:29 -0000	1.2
  +++ DisplayFilter.java	2 May 2003 04:19:26 -0000	1.3
  @@ -53,6 +53,7 @@
   import java.io.Serializable;
   
   import java.text.DateFormat;
  +import java.text.SimpleDateFormat;
   
   import java.util.Collection;
   import java.util.Date;
  @@ -70,9 +71,8 @@
    * @author Scott Deboy <sdeboy@apache.org>
    */
   public class DisplayFilter implements Serializable {
  -  private static final String LEVEL_COL_NAME = "Level";
     private static final DateFormat DATE_FORMATTER =
  -    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
  +    new SimpleDateFormat(ChainsawConstants.DATETIME_FORMAT);
     private transient Vector filterListeners = new Vector();
     private transient Vector filters = new Vector();
     private transient DisplayFilterEntry customFilter;
  @@ -111,7 +111,7 @@
           customFilter.matches(
               customFilter.getColumnName(),
               formatField(v.get(colNames.indexOf(customFilter.getColumnName())))
  -                .toString(), (String) v.get(colNames.indexOf(LEVEL_COL_NAME)))) {
  +                .toString(), (String) v.get(colNames.indexOf(ChainsawConstants.LEVEL_COL_NAME))))
{
           passesCustomFilter = customFilter.getDisplay().booleanValue();
         } else {
           passesCustomFilter = false;
  @@ -134,7 +134,7 @@
             entry.matches(
                 entry.getColumnName(),
                 (String) v.get(colNames.indexOf(entry.getColumnName())),
  -              (String) v.get(colNames.indexOf(LEVEL_COL_NAME)))) {
  +              (String) v.get(colNames.indexOf(ChainsawConstants.LEVEL_COL_NAME)))) {
             return passesCustomFilter && entry.getDisplay().booleanValue();
           }
         }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message