You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2010/08/16 08:14:38 UTC

svn commit: r985797 - /logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java

Author: sdeboy
Date: Mon Aug 16 06:14:38 2010
New Revision: 985797

URL: http://svn.apache.org/viewvc?rev=985797&view=rev
Log:
Minor bug fixes
 - Fixed bug preventing non-blank receiver properties from being set to blank (except for 'name' field)
 - Now only logging in VFS receiver panel if the file size grows or the file is truncated (not every time the file is examined for changes)
 - Fixed bug causing a specified receiver configuration to be loaded twice if loaded from the receiver configuration/selection screen
 - Updated LogFilePatternReceiver timestamp regexp support to escape dots in timestamps

Modified:
    logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java

Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java?rev=985797&r1=985796&r2=985797&view=diff
==============================================================================
--- logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java (original)
+++ logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java Mon Aug 16 06:14:38 2010
@@ -554,7 +554,7 @@ public class LogFilePatternReceiver exte
         try {
             regexpPattern = compiler.compile(regexp);
         } catch (MalformedPatternException mpe) {
-            throw new RuntimeException("Bad pattern: " + regexp);
+            throw new RuntimeException("Bad pattern: " + regexp, mpe);
         }
     }
 
@@ -603,7 +603,10 @@ public class LogFilePatternReceiver exte
   private String convertTimestamp() {
     //some locales (for example, French) generate timestamp text with characters not included in \w -
     // now using \S (all non-whitespace characters) instead of /w 
-    return util.substitute("s/("+VALID_DATEFORMAT_CHAR_PATTERN+")+/\\\\S+/g", timestampFormat);
+    String result = util.substitute("s/("+VALID_DATEFORMAT_CHAR_PATTERN+")+/\\\\S+/g", timestampFormat);
+    //make sure dots in timestamp are escaped
+    result = globalReplace(".", "\\.", result);
+    return result;
   }
 
     protected void setHost(String host) {
@@ -802,13 +805,18 @@ public class LogFilePatternReceiver exte
     {
         int propLength = oldString.length();
         int startPos = inputString.indexOf(oldString);
+        if (startPos == -1)
+        {
+            getLogger().info("string: " + oldString + " not found in input: " + inputString + " - returning input");
+            return inputString;
+        }
         if (startPos == 0)
-    {
-        inputString = inputString.substring(propLength);
-        inputString = newString + inputString;
-    } else {
-        inputString = inputString.substring(0, startPos) + newString + inputString.substring(startPos + propLength);
-    }
+        {
+            inputString = inputString.substring(propLength);
+            inputString = newString + inputString;
+        } else {
+            inputString = inputString.substring(0, startPos) + newString + inputString.substring(startPos + propLength);
+        }
         return inputString;
     }
 



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