logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1574176 - in /logging/log4j/log4j2/trunk: log4j-core/src/main/java/org/apache/logging/log4j/core/config/ log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/ log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/...
Date Tue, 04 Mar 2014 18:57:41 GMT
Author: ggregory
Date: Tue Mar  4 18:57:41 2014
New Revision: 1574176

URL: http://svn.apache.org/r1574176
Log:
<action issue="LOG4J2-561" dev="ggregory" type="update" due-to="vibin">
  Allow spaces around commas in Configuration's package attribute.
</action>

Added:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Patterns.java
  (with props)
Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/AnsiEscape.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java?rev=1574176&r1=1574175&r2=1574176&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
Tue Mar  4 18:57:41 2014
@@ -70,6 +70,9 @@ import org.apache.logging.log4j.util.Pro
  * The Base Configuration. Many configuration implementations will extend this class.
  */
 public class BaseConfiguration extends AbstractFilterable implements Configuration {
+    
+    static final String PACKAGE_SEPARATOR = "\\s*,\\s*";
+
     /**
      * Allow subclasses access to the status logger without creating another instance.
      */

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java?rev=1574176&r1=1574175&r2=1574176&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java
Tue Mar  4 18:57:41 2014
@@ -37,6 +37,7 @@ import org.apache.logging.log4j.core.con
 import org.apache.logging.log4j.core.config.plugins.PluginType;
 import org.apache.logging.log4j.core.config.plugins.ResolverUtil;
 import org.apache.logging.log4j.core.helpers.FileUtils;
+import org.apache.logging.log4j.core.helpers.Patterns;
 import org.apache.logging.log4j.status.StatusConsoleListener;
 import org.apache.logging.log4j.status.StatusListener;
 import org.apache.logging.log4j.status.StatusLogger;
@@ -109,7 +110,7 @@ public class JSONConfiguration extends B
                 } else if ("verbose".equalsIgnoreCase(entry.getKey())) {
                     verbose = Boolean.parseBoolean(getStrSubstitutor().replace(entry.getValue()));
                 } else if ("packages".equalsIgnoreCase(entry.getKey())) {
-                    final String[] packages = getStrSubstitutor().replace(entry.getValue()).split(",");
+                    final String[] packages = getStrSubstitutor().replace(entry.getValue()).split(Patterns.COMMA_SEPARATOR);
                     for (final String p : packages) {
                         PluginManager.addPackage(p);
                     }

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java?rev=1574176&r1=1574175&r2=1574176&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
Tue Mar  4 18:57:41 2014
@@ -47,6 +47,7 @@ import org.apache.logging.log4j.core.con
 import org.apache.logging.log4j.core.config.plugins.PluginType;
 import org.apache.logging.log4j.core.config.plugins.ResolverUtil;
 import org.apache.logging.log4j.core.helpers.FileUtils;
+import org.apache.logging.log4j.core.helpers.Patterns;
 import org.apache.logging.log4j.status.StatusConsoleListener;
 import org.apache.logging.log4j.status.StatusListener;
 import org.apache.logging.log4j.status.StatusLogger;
@@ -178,7 +179,7 @@ public class XMLConfiguration extends Ba
                 } else if ("verbose".equalsIgnoreCase(entry.getKey())) {
                     verbose = Boolean.parseBoolean(getStrSubstitutor().replace(entry.getValue()));
                 } else if ("packages".equalsIgnoreCase(getStrSubstitutor().replace(entry.getKey())))
{
-                    final String[] packages = entry.getValue().split(",");
+                    final String[] packages = entry.getValue().split(Patterns.COMMA_SEPARATOR);
                     for (final String p : packages) {
                         PluginManager.addPackage(p);
                     }

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java?rev=1574176&r1=1574175&r2=1574176&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
Tue Mar  4 18:57:41 2014
@@ -36,6 +36,7 @@ import java.util.concurrent.CopyOnWriteA
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.helpers.Closer;
 import org.apache.logging.log4j.core.helpers.Loader;
+import org.apache.logging.log4j.core.helpers.Patterns;
 import org.apache.logging.log4j.status.StatusLogger;
 
 /**
@@ -163,7 +164,7 @@ public class PluginManager {
                     PACKAGES.add(LOG4J_PACKAGES);
                 }
             } else {
-                final String[] names = pkgs.split(",");
+                final String[] names = pkgs.split(Patterns.COMMA_SEPARATOR);
                 for (final String name : names) {
                     PACKAGES.add(name);
                 }

Added: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Patterns.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Patterns.java?rev=1574176&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Patterns.java
(added)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Patterns.java
Tue Mar  4 18:57:41 2014
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.helpers;
+
+import java.util.regex.Pattern;
+
+/**
+ * Pattern strings used throughout Log4j.
+ * 
+ * @see Pattern
+ */
+public class Patterns {
+
+    /**
+     * A pattern string for comma separated lists with optional whitespace.
+     */
+    public static final String COMMA_SEPARATOR = toWhitespaceSeparator(",");
+
+    /**
+     * The whitespace pattern string.
+     */
+    public static final String WHITESPACE = "\\s*";
+
+    /**
+     * Creates a pattern string for {@code separator} surrounded by whitespace.
+     * 
+     * @param separator The separator.
+     * @return a pattern for {@code separator} surrounded by whitespace.
+     */
+    public static String toWhitespaceSeparator(final String separator) {
+        return WHITESPACE + separator + WHITESPACE;
+    }
+
+}

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Patterns.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/helpers/Patterns.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/AnsiEscape.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/AnsiEscape.java?rev=1574176&r1=1574175&r2=1574176&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/AnsiEscape.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/AnsiEscape.java
Tue Mar  4 18:57:41 2014
@@ -21,6 +21,8 @@ import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
+import org.apache.logging.log4j.core.helpers.Patterns;
+
 /**
  * Converts text into ANSI escape sequences.
  * <p>
@@ -209,8 +211,6 @@ public enum AnsiEscape {
      */
     BG_WHITE("47");
 
-    private static final String WHITESPACE_REGEX = "\\s*";
-
     private final String code;
 
     private AnsiEscape(final String code) {
@@ -226,10 +226,6 @@ public enum AnsiEscape {
         return PREFIX.getCode() + SUFFIX.getCode();
     }
 
-    private static String toRegexSeparator(final String separator) {
-        return WHITESPACE_REGEX + separator + WHITESPACE_REGEX;
-    }
-
     /**
      * Gets the escape code.
      *
@@ -260,7 +256,7 @@ public enum AnsiEscape {
      * @return a new map
      */
     public static Map<String, String> createMap(final String values, final String[]
dontEscapeKeys) {
-        return createMap(values.split(toRegexSeparator(",")), dontEscapeKeys);
+        return createMap(values.split(Patterns.toWhitespaceSeparator(",")), dontEscapeKeys);
     }
 
     /**
@@ -290,7 +286,7 @@ public enum AnsiEscape {
         Arrays.sort(sortedIgnoreKeys);
         final Map<String, String> map = new HashMap<String, String>();
         for (final String string : values) {
-            final String[] keyValue = string.split(toRegexSeparator("="));
+            final String[] keyValue = string.split(Patterns.toWhitespaceSeparator("="));
             if (keyValue.length > 1) {
                 final String key = keyValue[0].toUpperCase(Locale.ENGLISH);
                 final String value = keyValue[1];

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1574176&r1=1574175&r2=1574176&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Tue Mar  4 18:57:41 2014
@@ -21,6 +21,9 @@
   </properties>
   <body>
     <release version="2.0-rc2?" date="2014-MM-DD" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-561" dev="ggregory" type="update" due-to="vibin">
+        Allow spaces around commas in Configuration's package attribute.
+      </action>
       <action issue="LOG4J2-547" dev="rgoers" type="update" due-to="Bruce Brouwer">
         Have Logger API expose a PrintWriter instead of custom LoggerStream.
       </action>



Mime
View raw message