incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1520518 - in /sling/trunk/bundles/commons/log/src: main/java/ch/ main/java/ch/qos/ main/java/ch/qos/logback/ main/java/ch/qos/logback/classic/ main/java/ch/qos/logback/classic/util/ test/java/org/apache/sling/commons/log/logback/integration/
Date Fri, 06 Sep 2013 08:54:13 GMT
Author: cziegeler
Date: Fri Sep  6 08:54:13 2013
New Revision: 1520518

URL: http://svn.apache.org/r1520518
Log:
SLING-3037 : IllegalArgumentException in logback Logger. Apply patch from Chetan Mehrotra


Added:
    sling/trunk/bundles/commons/log/src/main/java/ch/
    sling/trunk/bundles/commons/log/src/main/java/ch/qos/
    sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/
    sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/
    sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/
    sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java
  (with props)
Modified:
    sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITDefaultConfig.java

Added: sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java?rev=1520518&view=auto
==============================================================================
--- sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java
(added)
+++ sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java
Fri Sep  6 08:54:13 2013
@@ -0,0 +1,69 @@
+/*
+ * 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 ch.qos.logback.classic.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.qos.logback.core.CoreConstants;
+
+/**
+ * Utility class for analysing logger names.
+ * Locally overriding the class for SLING-3037
+ */
+public class LoggerNameUtil {
+
+
+  public static int getFirstSeparatorIndexOf(String name) {
+    return getSeparatorIndexOf(name, 0);
+  }
+
+  /**
+   * Get the position of the separator character, if any, starting at position
+   * 'fromIndex'.
+   *
+   * @param name
+   * @param fromIndex
+   * @return
+   */
+  public static int getSeparatorIndexOf(String name, int fromIndex) {
+      int dotIndex = name.indexOf(CoreConstants.DOT, fromIndex);
+      int dollarIndex = name.indexOf(CoreConstants.DOLLAR, fromIndex);
+      if (dotIndex == -1 && dollarIndex == -1) return -1;
+      if (dotIndex == -1) return dollarIndex;
+      if (dollarIndex == -1) return dotIndex;
+      return dotIndex < dollarIndex ? dotIndex : dollarIndex;
+  }
+
+  public static List<String> computeNameParts(String loggerName) {
+    List<String> partList = new ArrayList<String>();
+
+    int fromIndex = 0;
+    while(true) {
+      int index = getSeparatorIndexOf(loggerName, fromIndex);
+      if(index == -1) {
+       partList.add(loggerName.substring(fromIndex));
+       break;
+      }
+      partList.add(loggerName.substring(fromIndex, index));
+      fromIndex = index+1;
+    }
+    return partList;
+  }
+}

Propchange: sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/commons/log/src/main/java/ch/qos/logback/classic/util/LoggerNameUtil.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITDefaultConfig.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITDefaultConfig.java?rev=1520518&r1=1520517&r2=1520518&view=diff
==============================================================================
--- sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITDefaultConfig.java
(original)
+++ sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/logback/integration/ITDefaultConfig.java
Fri Sep  6 08:54:13 2013
@@ -24,8 +24,6 @@ import java.util.Iterator;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.core.Appender;
-
-import org.apache.sling.commons.log.logback.integration.LogTestBase;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -70,4 +68,10 @@ public class ITDefaultConfig extends Log
         assertTrue("One appender should be attached with root logger", itr.hasNext());
     }
 
+    @Test
+    public void supportNestedClassesWithNestedDot() throws Exception {
+        //SLING-3037 - No illegalArgumentException thrown
+        LoggerFactory.getLogger("com.foo.Bar$Nested.dot");
+    }
+
 }



Mime
View raw message