logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carn...@apache.org
Subject svn commit: r502388 - in /logging/log4j/trunk: src/java/org/apache/log4j/ src/java/org/apache/log4j/config/ src/java/org/apache/log4j/db/dialect/ src/java/org/apache/log4j/helpers/ src/java/org/apache/log4j/lbel/ src/java/org/apache/log4j/rule/ tests/s...
Date Thu, 01 Feb 2007 22:44:06 GMT
Author: carnold
Date: Thu Feb  1 14:44:05 2007
New Revision: 502388

URL: http://svn.apache.org/viewvc?view=rev&rev=502388
Log:
Bug 40937: Reverting commit 500441 so unit tests pass

Modified:
    logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java
    logging/log4j/trunk/src/java/org/apache/log4j/Level.java
    logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java
    logging/log4j/trunk/src/java/org/apache/log4j/db/dialect/Util.java
    logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateLayout.java
    logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java
    logging/log4j/trunk/src/java/org/apache/log4j/helpers/OptionConverter.java
    logging/log4j/trunk/src/java/org/apache/log4j/helpers/UtilLoggingLevel.java
    logging/log4j/trunk/src/java/org/apache/log4j/lbel/TokenStream.java
    logging/log4j/trunk/src/java/org/apache/log4j/rule/InFixToPostFix.java
    logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelEqualsRule.java
    logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelInequalityRule.java
    logging/log4j/trunk/src/java/org/apache/log4j/rule/PartialTextMatchRule.java
    logging/log4j/trunk/src/java/org/apache/log4j/rule/RuleFactory.java
    logging/log4j/trunk/tests/src/java/org/apache/log4j/DRFATestCase.java
    logging/log4j/trunk/tests/src/java/org/apache/log4j/xml/XLevel.java

Modified: logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/HTMLLayout.java Thu Feb  1 14:44:05 2007
@@ -325,7 +325,7 @@
     for (int i = 0; i < patternConverters.length; i++) {
         PatternConverter c = patternConverters[i];
         sbuf.append("<td class=\"");
-        sbuf.append(c.getStyleClass(null));
+        sbuf.append(c.getStyleClass(null).toLowerCase());
         sbuf.append("\">");
         sbuf.append(c.getName());
         sbuf.append("</td>");
@@ -368,7 +368,7 @@
        oddCopy = odd;
     }
     
-    String level = event.getLevel().toString();
+    String level = event.getLevel().toString().toLowerCase();
 
     StringBuffer buf = new StringBuffer();
     buf.append(Layout.LINE_SEP);
@@ -384,7 +384,7 @@
     for(int i = 0; i < patternConverters.length; i++) {
         PatternConverter c = patternConverters[i];
         buf.append("<td class=\"");
-        buf.append(c.getStyleClass(event));
+        buf.append(c.getStyleClass(event).toLowerCase());
         buf.append("\">");
         int fieldStart = buf.length();
         c.format(event, buf);

Modified: logging/log4j/trunk/src/java/org/apache/log4j/Level.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/Level.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/Level.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/Level.java Thu Feb  1 14:44:05 2007
@@ -22,7 +22,6 @@
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
-import java.util.Locale;
 
 
 /**
@@ -213,7 +212,7 @@
       return defaultLevel;
     }
 
-    String s = sArg.toUpperCase(Locale.ENGLISH);
+    String s = sArg.toUpperCase();
 
     if (s.equals("ALL")) {
       return ALL;

Modified: logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/config/PropertySetter.java Thu Feb  1 14:44:05
2007
@@ -31,7 +31,6 @@
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Method;
 import java.util.Enumeration;
-import java.util.Locale;
 import java.util.Properties;
 
 
@@ -354,7 +353,7 @@
   }
 
   String capitalizeFirstLetter(String name) {
-    return name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1);
+    return name.substring(0, 1).toUpperCase() + name.substring(1);
   }
 
   /**

Modified: logging/log4j/trunk/src/java/org/apache/log4j/db/dialect/Util.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/db/dialect/Util.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/db/dialect/Util.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/db/dialect/Util.java Thu Feb  1 14:44:05
2007
@@ -21,13 +21,12 @@
 
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
-import java.util.Locale;
 
 
 /**
- * Database utilities.
  * 
  * @author Ceki Gulcu
+ *
  */
 public class Util extends ComponentBase {
   private static final String POSTGRES_PART = "postgresql";
@@ -37,15 +36,12 @@
   private static final String MSSQL_PART = "microsoft";
   private static final String HSQL_PART = "hsql";
   
-  /**
-   * Returns a dialect based on the product name in the {@link DatabaseMetaData}.
-   */
   public static int discoverSQLDialect(DatabaseMetaData meta) {
     int dialectCode = 0;
 
     try {
 
-      String dbName = meta.getDatabaseProductName().toLowerCase(Locale.ENGLISH);
+      String dbName = meta.getDatabaseProductName().toLowerCase();
 
       if (dbName.indexOf(POSTGRES_PART) != -1) {
         return ConnectionSource.POSTGRES_DIALECT;

Modified: logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateLayout.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateLayout.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateLayout.java Thu Feb  1 14:44:05
2007
@@ -108,7 +108,7 @@
     public
     void setOption(final String option, final String value) {
       if(option.equalsIgnoreCase(DATE_FORMAT_OPTION)) {
-        dateFormatOption = value;
+        dateFormatOption = value.toUpperCase();
       } else if(option.equalsIgnoreCase(TIMEZONE_OPTION)) {
         timeZoneID = value;
       }

Modified: logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/helpers/DateTimeDateFormat.java Thu Feb
 1 14:44:05 2007
@@ -34,6 +34,8 @@
      * Equivalent format string for SimpleDateFormat.
      */
     private final static String PATTERN = "dd MMM yyyy HH:mm:ss,SSS";
+    /** Short names for the months. */
+    String[] shortMonths = new DateFormatSymbols().getShortMonths();
 
     /**
      * Create a new instance of DateTimeDateFormat.

Modified: logging/log4j/trunk/src/java/org/apache/log4j/helpers/OptionConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/helpers/OptionConverter.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/helpers/OptionConverter.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/helpers/OptionConverter.java Thu Feb  1
14:44:05 2007
@@ -27,7 +27,6 @@
 
 import java.net.URL;
 
-import java.util.Locale;
 import java.util.Properties;
 
 
@@ -276,7 +275,7 @@
       return dEfault;
     }
 
-    String s = value.trim().toUpperCase(Locale.ENGLISH);
+    String s = value.trim().toUpperCase();
     long multiplier = 1;
     int index;
 

Modified: logging/log4j/trunk/src/java/org/apache/log4j/helpers/UtilLoggingLevel.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/helpers/UtilLoggingLevel.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/helpers/UtilLoggingLevel.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/helpers/UtilLoggingLevel.java Thu Feb  1
14:44:05 2007
@@ -18,7 +18,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Locale;
 
 import org.apache.log4j.Level;
 
@@ -112,12 +111,13 @@
       return defaultLevel;
     }
 
-    String s = sArg.toUpperCase(Locale.ENGLISH);
+    String s = sArg.toUpperCase();
 
     if (s.equals("SEVERE")) {
       return SEVERE;
     }
 
+    //if(s.equals("FINE")) return Level.FINE; 
     if (s.equals("WARNING")) {
       return WARNING;
     }
@@ -126,7 +126,7 @@
       return INFO;
     }
 
-    if (s.equals("CONFIG")) {
+    if (s.equals("CONFI")) {
       return CONFIG;
     }
 

Modified: logging/log4j/trunk/src/java/org/apache/log4j/lbel/TokenStream.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/lbel/TokenStream.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/lbel/TokenStream.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/lbel/TokenStream.java Thu Feb  1 14:44:05
2007
@@ -21,7 +21,6 @@
 import java.io.Reader;
 import java.io.StreamTokenizer;
 import java.util.HashMap;
-import java.util.Locale;
 import java.util.Map;
 
 
@@ -98,7 +97,7 @@
 		    break;
   		case StreamTokenizer.TT_WORD:
   			String txt = tokenizer.sval;
-        String lowerCaseTxt = txt.toLowerCase(Locale.ENGLISH);
+        String lowerCaseTxt = txt.toLowerCase();
    		  Token result = (Token) keywordMap.get(lowerCaseTxt);
  		    if(result != null) {
   	  	  current = result;

Modified: logging/log4j/trunk/src/java/org/apache/log4j/rule/InFixToPostFix.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/rule/InFixToPostFix.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/rule/InFixToPostFix.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/rule/InFixToPostFix.java Thu Feb  1 14:44:05
2007
@@ -18,7 +18,6 @@
 
 import java.util.HashMap;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Stack;
 import java.util.StringTokenizer;
@@ -90,14 +89,14 @@
   }
 
   boolean isOperand(String symbol) {
-    symbol = symbol.toLowerCase(Locale.ENGLISH);
+    symbol = symbol.toLowerCase();
 
     return (!operators.contains(symbol));
   }
 
   boolean precedes(String symbol1, String symbol2) {
-    symbol1 = symbol1.toLowerCase(Locale.ENGLISH);
-    symbol2 = symbol2.toLowerCase(Locale.ENGLISH);
+    symbol1 = symbol1.toLowerCase();
+    symbol2 = symbol2.toLowerCase();
 
     if (!precedenceMap.keySet().contains(symbol1)) {
       return false;

Modified: logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelEqualsRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelEqualsRule.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelEqualsRule.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelEqualsRule.java Thu Feb  1 14:44:05
2007
@@ -19,7 +19,6 @@
 import java.io.IOException;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Locale;
 
 import org.apache.log4j.Level;
 import org.apache.log4j.helpers.UtilLoggingLevel;
@@ -35,15 +34,35 @@
 
     private transient Level level;
 
+    private static List levelList = new LinkedList();
+
+    static {
+        populateLevels();
+    }
+    
     private LevelEqualsRule(Level level) {
         this.level = level;
     }
 
+    private static void populateLevels() {
+        levelList = new LinkedList();
+
+        levelList.add(Level.FATAL.toString());
+        levelList.add(Level.ERROR.toString());
+        levelList.add(Level.WARN.toString());
+        levelList.add(Level.INFO.toString());
+        levelList.add(Level.DEBUG.toString());
+        levelList.add(Level.TRACE.toString());
+    }
+
     public static Rule getRule(String value) {
-        Level thisLevel = Level.toLevel(value, null);
-        if (thisLevel == null) {
-           thisLevel = UtilLoggingLevel.toLevel(value);
+        Level thisLevel = null;
+        if (levelList.contains(value.toUpperCase())) {
+            thisLevel = Level.toLevel(value.toUpperCase());
+          } else {
+              thisLevel = UtilLoggingLevel.toLevel(value.toUpperCase());
         }
+
         return new LevelEqualsRule(thisLevel);
     }
 
@@ -59,6 +78,7 @@
      * @throws IOException
      */
     private void readObject(java.io.ObjectInputStream in) throws IOException {
+        populateLevels();
         boolean isUtilLogging = in.readBoolean();
         int levelInt = in.readInt();
         if (isUtilLogging) {

Modified: logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelInequalityRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelInequalityRule.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelInequalityRule.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/rule/LevelInequalityRule.java Thu Feb  1
14:44:05 2007
@@ -30,10 +30,38 @@
  * @author Scott Deboy <sdeboy@apache.org>
  */
 public class LevelInequalityRule {
+    private static List levelList;
+    private static List utilLoggingLevelList;
+
+    static {
+        populateLevels();
+    }
 
     private LevelInequalityRule() {
     }
     
+    private static void populateLevels() {
+        levelList = new LinkedList();
+
+        levelList.add(Level.FATAL.toString());
+        levelList.add(Level.ERROR.toString());
+        levelList.add(Level.WARN.toString());
+        levelList.add(Level.INFO.toString());
+        levelList.add(Level.DEBUG.toString());
+        levelList.add(Level.TRACE.toString());
+        
+        utilLoggingLevelList = new LinkedList();
+
+        utilLoggingLevelList.add(UtilLoggingLevel.SEVERE.toString());
+        utilLoggingLevelList.add(UtilLoggingLevel.WARNING.toString());
+        utilLoggingLevelList.add(UtilLoggingLevel.INFO.toString());
+        utilLoggingLevelList.add(UtilLoggingLevel.CONFIG.toString());
+        utilLoggingLevelList.add(UtilLoggingLevel.FINE.toString());
+        utilLoggingLevelList.add(UtilLoggingLevel.FINER.toString());
+        utilLoggingLevelList.add(UtilLoggingLevel.FINEST.toString());
+
+    }
+
     public static Rule getRule(String inequalitySymbol, String value) {
 
         Level thisLevel = null;
@@ -43,11 +71,11 @@
         
         //an illegalargumentexception is only generated if the user types a level name
         //that doesn't exist as either a log4j or util.logging level name
-        thisLevel = Level.toLevel(value, null);
-        if (thisLevel == null) {
-            thisLevel = UtilLoggingLevel.toLevel(value);
-        } 
-        if (thisLevel == null) {
+        if (levelList.contains(value.toUpperCase())) {
+            thisLevel = Level.toLevel(value.toUpperCase());
+        } else if (utilLoggingLevelList.contains(value.toUpperCase())){
+            thisLevel = UtilLoggingLevel.toLevel(value.toUpperCase());
+        } else {
             throw new IllegalArgumentException("Invalid level inequality rule - " + value
+ " is not a supported level");
         }
 

Modified: logging/log4j/trunk/src/java/org/apache/log4j/rule/PartialTextMatchRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/rule/PartialTextMatchRule.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/rule/PartialTextMatchRule.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/rule/PartialTextMatchRule.java Thu Feb 
1 14:44:05 2007
@@ -19,7 +19,6 @@
 import org.apache.log4j.spi.LoggingEvent;
 import org.apache.log4j.spi.LoggingEventFieldResolver;
 
-import java.util.Locale;
 import java.util.Stack;
 
 
@@ -64,9 +63,8 @@
 
   public boolean evaluate(LoggingEvent event) {
     Object p2 = resolver.getValue(field, event);
-    if (p2 == null || value == null)
-      return false;
-    String s = p2.toString().toLowerCase(Locale.ENGLISH);
-    return s.indexOf(value.toLowerCase(Locale.ENGLISH)) != -1;
+
+    return ((p2 != null) && (value != null)
+    && (p2.toString().toLowerCase().indexOf(value.toLowerCase()) > -1));
   }
 }

Modified: logging/log4j/trunk/src/java/org/apache/log4j/rule/RuleFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/rule/RuleFactory.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/rule/RuleFactory.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/rule/RuleFactory.java Thu Feb  1 14:44:05
2007
@@ -20,7 +20,6 @@
 import java.lang.reflect.Method;
 import java.util.Collection;
 import java.util.LinkedList;
-import java.util.Locale;
 import java.util.Stack;
 import org.apache.log4j.LogManager;
 
@@ -75,10 +74,7 @@
   }
   
   public boolean isRule(String symbol) {
-    if (symbol == null)
-      return false;
-    symbol = symbol.toLowerCase(Locale.ENGLISH);
-    return rules.contains(symbol);
+    return ((symbol != null) && (rules.contains(symbol.toLowerCase())));
   }
 
   public Rule getRule(String symbol, Stack stack) {

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/DRFATestCase.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/DRFATestCase.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/DRFATestCase.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/DRFATestCase.java Thu Feb  1 14:44:05
2007
@@ -21,7 +21,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.Calendar;
-import java.util.Locale;
 import java.util.TimeZone;
 import java.util.Date;
 import java.text.SimpleDateFormat;
@@ -414,7 +413,7 @@
         Logger root = Logger.getRootLogger();
         root.addAppender(appender);
         File firstFile =
-                new File(filename + new SimpleDateFormat(pattern, Locale.ENGLISH).format(new
Date()));
+                new File(filename + new SimpleDateFormat(pattern).format(new Date()));
         root.info("Hello, World");
         //
         //   create a file by that name so it has to be deleted

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/xml/XLevel.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/tests/src/java/org/apache/log4j/xml/XLevel.java?view=diff&rev=502388&r1=502387&r2=502388
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/xml/XLevel.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/xml/XLevel.java Thu Feb  1 14:44:05
2007
@@ -16,8 +16,6 @@
 
 package org.apache.log4j.xml;
 
-import java.util.Locale;
-
 import org.apache.log4j.Level;
 
 
@@ -54,7 +52,7 @@
       return defaultValue;
     }
 
-    String stringVal = sArg.toUpperCase(Locale.ENGLISH);
+    String stringVal = sArg.toUpperCase();
 
     if (stringVal.equals(TRACE_STR)) {
       return XLevel.TRACE;



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


Mime
View raw message